Skip to main content

kova_api/
lib.rs

1//! kova-api: HTTP API.
2//!
3//! `GET /health` — liveness probe.
4//! `GET /` — embedded GUI (from `kova-gui`).
5//! `GET /pipeline/state` / `GET /pipeline/events` / `POST /pipeline/research`
6//! — engine endpoints, wired in via [`engine::router_with_engine`].
7
8pub mod engine;
9pub mod gui;
10
11use axum::{routing::get, Router};
12
13/// Build the base API router (health + GUI).
14pub fn router() -> Router {
15    Router::new()
16        .route("/health", get(gui::health))
17        .route("/", get(gui::index))
18}
19
20#[cfg(test)]
21mod tests {
22    use super::*;
23
24    #[test]
25    fn router_builds() {
26        let _ = router();
27    }
28
29    #[tokio::test]
30    async fn health_payload_is_ok() {
31        let v = gui::health().await.0;
32        assert_eq!(v["status"], "ok");
33        assert_eq!(v["service"], "kova");
34    }
35
36    #[tokio::test]
37    async fn index_serves_embedded_gui() {
38        let (_, html) = gui::index().await;
39        assert!(html.contains("Kova"));
40    }
41}