intent-engine 0.11.1

A command-line database service for tracking strategic intent, tasks, and events
Documentation
use axum::{
    routing::{get, post, put},
    Router,
};

use super::handlers;
use super::server::AppState;

/// Create API router with all endpoints
pub fn api_routes() -> Router<AppState> {
    Router::new()
        // Task management routes
        .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))
        // Task done is a global operation
        .route("/tasks/done", post(handlers::done_task))
        // Event routes
        .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),
        )
        // Global routes
        .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))
        // Internal routes (CLI → Dashboard communication)
        .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() {
        // This just verifies the routes can be created without panic
        let _router = api_routes();
    }
}