intent_engine/dashboard/
routes.rs1use axum::{
2 routing::{get, post, put},
3 Router,
4};
5
6use super::handlers;
7use super::server::AppState;
8
9pub fn api_routes() -> Router<AppState> {
11 Router::new()
12 .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 .route("/tasks/done", post(handlers::done_task))
26 .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 .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 .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 let _router = api_routes();
57 }
58}