34 lines
1021 B
Rust
34 lines
1021 B
Rust
//! `/api/team-templates/*` — expose builtin + workspace team templates
|
|
//! to the wizard's team-picker step.
|
|
|
|
use axum::{
|
|
extract::{Path, State},
|
|
Json,
|
|
};
|
|
use cm_db::repo::team_templates::{TeamTemplate, TeamTemplateDetail};
|
|
use uuid::Uuid;
|
|
|
|
use crate::{ApiError, AppState, Authed};
|
|
|
|
pub async fn list(
|
|
State(state): State<AppState>,
|
|
Authed(_user): Authed,
|
|
) -> Result<Json<Vec<TeamTemplate>>, ApiError> {
|
|
// Builtins are cross-workspace; workspace-authored templates are
|
|
// filtered by the repo layer (this route only exposes builtins for
|
|
// now — Slice 3 doesn't ship a workspace template editor yet).
|
|
let rows = cm_db::repo::team_templates::list_all(&state.pool).await?;
|
|
Ok(Json(rows))
|
|
}
|
|
|
|
pub async fn get(
|
|
State(state): State<AppState>,
|
|
Authed(_user): Authed,
|
|
Path(id): Path<Uuid>,
|
|
) -> Result<Json<TeamTemplateDetail>, ApiError> {
|
|
let d = cm_db::repo::team_templates::get(&state.pool, id)
|
|
.await?
|
|
.ok_or(ApiError::NotFound)?;
|
|
Ok(Json(d))
|
|
}
|