use super::logic;
use crate::error::{run_blocking, AppError};
use axum::{
extract::{Path, State},
Json,
};
use logic::{Routine, RoutineStore};
#[utoipa::path(post, path = "/routines/{id}/trigger",
params(("id" = String, Path, description = "Routine UUID")),
responses((status = 200, body = Routine), (status = 404, description = "Not found")))]
pub async fn trigger_routine(
State(store): State<RoutineStore>,
Path(id): Path<String>,
) -> Result<Json<Routine>, AppError> {
let resp = run_blocking(move || logic::build(&store, &id)).await?;
Ok(Json(resp))
}
#[cfg(test)]
#[path = "http_tests.rs"]
mod http_tests;