intent_engine/dashboard/
routes.rs

1use axum::{
2    routing::{get, post, put},
3    Router,
4};
5
6use super::handlers;
7use super::server::AppState;
8
9/// Create API router with all endpoints
10pub fn api_routes() -> Router<AppState> {
11    Router::new()
12        // Task management routes
13        .route("/tasks", get(handlers::list_tasks).post(handlers::create_task))
14        .route(
15            "/tasks/:id",
16            get(handlers::get_task)
17                .put(handlers::update_task)
18                .patch(handlers::update_task)
19                .delete(handlers::delete_task),
20        )
21        .route("/tasks/:id/start", post(handlers::start_task))
22        .route("/tasks/:id/spawn-subtask", post(handlers::spawn_subtask))
23        .route("/tasks/:id/context", get(handlers::get_task_context))
24        // Task done is a global operation
25        .route("/tasks/done", post(handlers::done_task))
26        // Event routes
27        .route(
28            "/tasks/:id/events",
29            get(handlers::list_events).post(handlers::create_event),
30        )
31        .route(
32            "/tasks/:id/events/:event_id",
33            put(handlers::update_event)
34                .patch(handlers::update_event)
35                .delete(handlers::delete_event),
36        )
37        // Global routes
38        .route("/current-task", get(handlers::get_current_task))
39        .route("/pick-next", get(handlers::pick_next_task))
40        .route("/search", get(handlers::search))
41        .route("/projects", get(handlers::list_projects))
42        .route("/switch-project", post(handlers::switch_project))
43        .route("/remove-project", post(handlers::remove_project))
44        // Internal routes (CLI → Dashboard communication)
45        .route("/internal/cli-notify", post(handlers::handle_cli_notification))
46        .route("/internal/shutdown", post(handlers::shutdown_handler))
47}
48
49#[cfg(test)]
50mod tests {
51    use super::*;
52
53    #[test]
54    fn test_api_routes_creation() {
55        // This just verifies the routes can be created without panic
56        let _router = api_routes();
57    }
58}