use axum::{
routing::{get, post, put},
Router,
};
use super::handlers;
use super::server::AppState;
pub fn api_routes() -> Router<AppState> {
Router::new()
.route("/tasks", get(handlers::list_tasks).post(handlers::create_task))
.route(
"/tasks/:id",
get(handlers::get_task)
.put(handlers::update_task)
.patch(handlers::update_task)
.delete(handlers::delete_task),
)
.route("/tasks/:id/start", post(handlers::start_task))
.route("/tasks/:id/spawn-subtask", post(handlers::spawn_subtask))
.route("/tasks/:id/context", get(handlers::get_task_context))
.route("/tasks/done", post(handlers::done_task))
.route(
"/tasks/:id/events",
get(handlers::list_events).post(handlers::create_event),
)
.route(
"/tasks/:id/events/:event_id",
put(handlers::update_event)
.patch(handlers::update_event)
.delete(handlers::delete_event),
)
.route("/current-task", get(handlers::get_current_task))
.route("/pick-next", get(handlers::pick_next_task))
.route("/search", get(handlers::search))
.route("/projects", get(handlers::list_projects))
.route("/switch-project", post(handlers::switch_project))
.route("/remove-project", post(handlers::remove_project))
.route("/internal/cli-notify", post(handlers::handle_cli_notification))
.route("/internal/shutdown", post(handlers::shutdown_handler))
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_api_routes_creation() {
let _router = api_routes();
}
}