Skip to main content

mentedb_server/
routes.rs

1//! Route definitions for the MenteDB REST API.
2
3use std::sync::Arc;
4
5use axum::Router;
6use axum::routing::{get, post};
7
8use crate::handlers;
9use crate::state::AppState;
10use crate::websocket;
11
12/// Build the complete axum router with all v1 API routes.
13pub fn build_router(state: Arc<AppState>) -> Router {
14    Router::new()
15        .route("/v1/health", get(handlers::health))
16        .route("/v1/memories", post(handlers::store_memory))
17        .route(
18            "/v1/memories/{id}",
19            get(handlers::get_memory).delete(handlers::forget_memory),
20        )
21        .route("/v1/recall", post(handlers::recall_memories))
22        .route("/v1/search", post(handlers::search_similar))
23        .route("/v1/edges", post(handlers::create_edge))
24        .route("/v1/stats", get(handlers::stats))
25        .route("/v1/ingest", post(handlers::ingest_conversation))
26        .route("/v1/auth/token", post(crate::auth::generate_token))
27        .route(
28            "/v1/spaces",
29            post(handlers::create_space).get(handlers::list_spaces),
30        )
31        .route("/v1/spaces/{id}/grant", post(handlers::grant_space_access))
32        .route("/v1/ws/stream", get(websocket::ws_handler))
33        .with_state(state)
34}