Skip to content
Clone
a06673b
34 lines 931 B Rust
use axum::Json;
use axum::extract::{Path, Query, State};
use jwt::extractor::AuthUser;
use uuid::Uuid;
use crate::error::RepoResult;
use crate::features::RepoService;
use crate::features::extras::UserMini;
#[derive(serde::Deserialize, utoipa::IntoParams)]
pub struct StargazerQuery {
pub page: Option<u64>,
pub limit: Option<u64>,
}
#[utoipa::path(
get,
path = "/repo/{channel_id}/{repo_id}/stargazers",
tag = "repo",
params(StargazerQuery),
responses((status = 200, description = "List stargazers", body = Vec<UserMini>)),
security(("bearer_auth" = []))
)]
pub(crate) async fn handler(
State(svc): State<RepoService>,
AuthUser { claims }: AuthUser,
Path((_, repo_id)): Path<(Uuid, Uuid)>,
Query(q): Query<StargazerQuery>,
) -> RepoResult<Json<Vec<UserMini>>> {
let out = svc
.list_stargazers(claims.sub, repo_id, q.page, q.limit)
.await?;
Ok(Json(out))
}