use std::sync::Arc;
use axum::extract::State;
use axum::routing::get;
use axum::{Json, Router};
use serde::Serialize;
use utoipa::ToSchema;
use crate::api::AppState;
use crate::store::WorkflowStore;
pub fn router<S: WorkflowStore + 'static>() -> Router<Arc<AppState<S>>> {
Router::new()
.route("/health", get(health_check))
.route("/version", get(version))
}
#[utoipa::path(
get, path = "/api/v1/health",
tag = "public",
responses((status = 200, description = "Engine health — always unauthenticated")),
)]
pub async fn health_check() -> Json<serde_json::Value> {
Json(serde_json::json!({
"status": "ok",
"service": "assay-workflow",
}))
}
#[derive(Serialize, ToSchema)]
pub struct VersionInfo {
pub version: &'static str,
pub build_profile: &'static str,
}
#[utoipa::path(
get, path = "/api/v1/version",
tag = "public",
responses((status = 200, description = "Engine version info", body = VersionInfo)),
)]
pub async fn version<S: WorkflowStore>(
State(state): State<Arc<AppState<S>>>,
) -> Json<VersionInfo> {
let version = state
.binary_version
.unwrap_or(env!("CARGO_PKG_VERSION"));
Json(VersionInfo {
version,
build_profile: if cfg!(debug_assertions) {
"debug"
} else {
"release"
},
})
}