Files
keep/src/modes/server/api/mod.rs
Andrew Phillips b3a21d1f7c refactor: remove item/latest and item/{item_id} routes and handlers
Co-authored-by: aider (openai/andrew/openrouter/qwen/qwen3-coder) <aider@aider.chat>
2025-08-25 18:09:20 -03:00

77 lines
2.5 KiB
Rust

pub mod item;
pub mod status;
pub mod mcp;
use axum::{
routing::get,
Router,
};
use crate::modes::server::common::AppState;
use utoipa::OpenApi;
use utoipa_swagger_ui::SwaggerUi;
#[derive(OpenApi)]
#[openapi(
info(
title = "Keep API",
version = "0.1.0",
description = "REST API for Keep - a tool to manage temporary files with automatic compression and metadata generation",
contact(
name = "Keep Project",
)
),
paths(
status::handle_status,
item::handle_list_items,
item::handle_post_item,
item::handle_get_item_latest_meta,
item::handle_get_item_latest_content,
item::handle_get_item_meta,
item::handle_get_item_content,
mcp::handle_mcp_sse,
),
components(
schemas(
crate::modes::server::common::ItemInfo,
crate::modes::server::common::ItemContentInfo,
crate::modes::server::common::ItemInfoListResponse,
crate::modes::server::common::ItemInfoResponse,
crate::modes::server::common::ItemContentInfoResponse,
crate::modes::server::common::MetadataResponse,
crate::modes::server::common::StatusInfoResponse,
crate::common::status::StatusInfo,
)
),
tags(
(name = "status", description = "System status and health check endpoints"),
(name = "item", description = "Item management endpoints for storing, retrieving, and managing content with metadata"),
(name = "mcp", description = "Model Context Protocol endpoints for AI tool integration")
),
servers(
(url = "/", description = "Local server")
)
)]
struct ApiDoc;
pub fn add_routes(router: Router<AppState>) -> Router<AppState> {
router
// Status endpoints
.route("/api/status", get(status::handle_status))
// Item endpoints
.route("/api/item/", get(item::handle_list_items).post(item::handle_post_item))
.route("/api/item/latest/meta", get(item::handle_get_item_latest_meta))
.route("/api/item/latest/content", get(item::handle_get_item_latest_content))
.route("/api/item/{item_id}/meta", get(item::handle_get_item_meta))
.route("/api/item/{item_id}/content", get(item::handle_get_item_content))
// MCP endpoints
.route("/mcp/sse", get(mcp::handle_mcp_sse))
}
pub fn add_docs_routes(router: Router<AppState>) -> Router<AppState> {
router
.merge(SwaggerUi::new("/swagger").url("/openapi.json", ApiDoc::openapi()))
}