use serde::{Deserialize, Serialize}; use std::collections::HashMap; #[derive(Debug, Deserialize, Serialize)] pub struct RegisterAppRequest { pub app_name: String, pub script_path: String, pub working_directory: String, pub user: String, #[serde(default)] pub environment: HashMap, #[serde(default = "default_restart_policy")] pub restart_policy: String, pub app_type: String, pub description: Option, /// Ruta personalizada del ejecutable (node, npm, python). Si es None, se auto-detecta. #[serde(default)] pub custom_executable: Option, /// Si true, usa 'npm start' en lugar de 'node script.js' (solo para NodeJs) #[serde(default)] pub use_npm_start: Option, } fn default_restart_policy() -> String { "always".to_string() } #[derive(Debug, Serialize)] pub struct ApiResponse { pub success: bool, pub data: Option, pub error: Option, } impl ApiResponse { pub fn success(data: T) -> Self { ApiResponse { success: true, data: Some(data), error: None, } } pub fn error(error: String) -> Self { ApiResponse { success: false, data: None, error: Some(error), } } } #[derive(Debug, Serialize)] pub struct AppStatusResponse { pub name: String, pub status: String, pub pid: Option, pub cpu_usage: f32, pub memory_usage: String, pub systemd_status: String, pub last_updated: String, } #[derive(Debug, Serialize)] pub struct AppListResponse { pub apps: Vec, pub total: usize, } #[derive(Debug, Serialize)] pub struct OperationResponse { pub app_name: String, pub operation: String, pub success: bool, pub message: String, } #[derive(Debug, Serialize)] pub struct DetectedProcess { pub pid: i32, pub name: String, pub user: Option, pub cpu_usage: f64, pub memory_mb: f64, pub process_type: String, } #[derive(Debug, Serialize)] pub struct ProcessScanResponse { pub processes: Vec, pub total: usize, } #[derive(Debug, Serialize)] pub struct HealthResponse { pub status: String, pub config_loaded: bool, pub config_path: String, pub apps_count: usize, pub systemd_services: Vec, pub version: String, }