Files
clawmates/crates/cm-api/src/routes/team_templates.rs
T
Omar Sobh ee675b976a
ci / gates (push) Successful in 4s
ci / frontend (push) Successful in 25s
ci / rust (push) Failing after 50s
ci / e2e (push) Skipped
ci / publish (push) Skipped
fmt: apply cargo fmt to team template + loader
2026-07-19 12:42:39 -07:00

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))
}