1use topcoat::{
4 Result,
5 context::Cx,
6 router::{
7 content::{Css, Json},
8 query_params, route,
9 },
10};
11
12use crate::{data::load, params::UsageParams, style::CSS};
13
14#[route(GET "/api/report")]
16async fn report(cx: &Cx) -> Result<Json<Vec<tokenburn_core::ReportRow>>> {
17 let query = query_params::<UsageParams>(cx)?.to_query();
18 Ok(Json(load(query, &Default::default()).await.report))
19}
20
21#[route(GET "/api/health")]
23async fn health() -> Result<Json<&'static str>> {
24 Ok(Json("ok"))
25}
26
27#[route(GET "/api/themes")]
29async fn themes() -> Result<Json<serde_json::Value>> {
30 Ok(Json(crate::theme::catalogue()))
31}
32
33#[route(GET "/style.css")]
34async fn style() -> Result<Css<&'static str>> {
35 Ok(Css(CSS))
36}