use topcoat::{
Result,
context::Cx,
router::{
content::{Css, Json},
query_params, route,
},
};
use crate::{data::load, params::UsageParams, style::CSS};
#[route(GET "/api/report")]
async fn report(cx: &Cx) -> Result<Json<Vec<tokenburn_core::ReportRow>>> {
let query = query_params::<UsageParams>(cx)?.to_query();
Ok(Json(
load(query, &Default::default(), tokenburn_core::Currency::USD)
.await
.report,
))
}
#[route(GET "/api/health")]
async fn health() -> Result<Json<&'static str>> {
Ok(Json("ok"))
}
#[route(GET "/api/themes")]
async fn themes() -> Result<Json<serde_json::Value>> {
Ok(Json(crate::theme::catalogue()))
}
#[route(GET "/style.css")]
async fn style() -> Result<Css<&'static str>> {
Ok(Css(CSS))
}
#[route(GET "/cyberpunk.css")]
async fn cyberpunk_style() -> Result<Css<&'static str>> {
Ok(Css(crate::theme::CYBERPUNK_CSS))
}