From 703ae3b77653113c930c3bfee73e2fa59517c201 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Tue, 12 Aug 2025 14:32:44 -0300 Subject: [PATCH] refactor: remove redundant server modules after api refactoring Co-authored-by: aider (openai/andrew/openrouter/qwen/qwen3-coder) --- src/modes/server/api.rs | 23 +----------- src/modes/server/status.rs | 77 -------------------------------------- 2 files changed, 1 insertion(+), 99 deletions(-) diff --git a/src/modes/server/api.rs b/src/modes/server/api.rs index 2eef426..cb6cdf7 100644 --- a/src/modes/server/api.rs +++ b/src/modes/server/api.rs @@ -3,25 +3,4 @@ use axum::{ Router, }; -use crate::modes::server::common::AppState; - -pub mod item; -pub mod status; -pub mod docs; - -pub fn api_routes() -> Router { - Router::new() - // Item endpoints - .route("/api/item/", get(item::handle_list_items).post(item::handle_post_item)) - .route("/api/item/latest", get(item::handle_get_item_latest)) - .route("/api/item/latest/meta", get(item::handle_get_item_latest_meta)) - .route("/api/item/latest/content", get(item::handle_get_content_latest_raw)) - .route("/api/item/:id", get(item::handle_get_item).delete(item::handle_delete_item)) - .route("/api/item/:id/meta", get(item::handle_get_item_meta)) - .route("/api/item/:id/content", get(item::handle_get_content_raw)) - // Status endpoint - .route("/api/status", get(status::handle_status)) - // Documentation endpoints - .route("/api/openapi.json", get(docs::handle_openapi)) - .route("/api/docs", get(docs::handle_swagger_ui)) -} +use \ No newline at end of file diff --git a/src/modes/server/status.rs b/src/modes/server/status.rs index 576cde5..e69de29 100644 --- a/src/modes/server/status.rs +++ b/src/modes/server/status.rs @@ -1,77 +0,0 @@ -use axum::{ - extract::{ConnectInfo, State}, - http::{HeaderMap, StatusCode}, - response::Json, -}; -use clap::Command; -use log::warn; -use serde_json::json; -use std::net::SocketAddr; - -use crate::meta_plugin::MetaPluginType; -use crate::modes::status::{StatusInfo, generate_status_info}; -use super::common::{AppState, ApiResponse, check_auth}; - -pub async fn handle_status( - State(state): State, - headers: HeaderMap, - ConnectInfo(addr): ConnectInfo, -) -> Result>, StatusCode> { - if !check_auth(&headers, &state.password) { - warn!("Unauthorized request from {}", addr); - return Err(StatusCode::UNAUTHORIZED); - } - - // Use the actual args that the server was started with - let args = &state.args; - - // Determine which meta plugins would be enabled for a save operation - let mut meta_plugin_types: Vec = crate::modes::common::cmd_args_meta_plugin_types(&mut Command::new("keep"), args); - - // Add digest type if specified - let digest_type = crate::modes::common::cmd_args_digest_type(&mut Command::new("keep"), args); - let digest_meta_plugin_type = match digest_type { - crate::meta_plugin::MetaPluginType::DigestSha256 => Some(MetaPluginType::DigestSha256), - crate::meta_plugin::MetaPluginType::DigestMd5 => Some(MetaPluginType::DigestMd5), - _ => None, - }; - - if let Some(digest_plugin_type) = digest_meta_plugin_type { - if !meta_plugin_types.contains(&digest_plugin_type) { - meta_plugin_types.push(digest_plugin_type); - } - } - - let mut db_path = state.data_dir.clone(); - db_path.push("keep-1.db"); - - let status_info = generate_status_info(state.data_dir.clone(), db_path, &meta_plugin_types); - - let response = ApiResponse { - success: true, - data: Some(status_info), - error: None, - }; - - Ok(Json(response)) -} - -pub fn get_status_openapi_spec() -> serde_json::Value { - json!({ - "/api/status": { - "get": { - "summary": "Get system status", - "responses": { - "200": { - "description": "System status", - "content": { - "application/json": { - "schema": {"$ref": "#/components/schemas/StatusInfo"} - } - } - } - } - } - } - }) -}