use std::sync::Arc;

use axum::Json;
use axum::extract::State;
use serde_json::{Value, json};

use crate::config::Config;
use crate::settings::Settings;

pub async fn handle_health(
    State(config): State<Arc<Config>>,
    State(settings): State<Arc<Settings>>,
) -> Json<Value> {
    Json(json!({
        "status": "ok",
        "port": config.server_port,
        "data_path": config.data_path.to_string_lossy(),
        "users": config.users.iter().map(|u| &u.slug).collect::<Vec<_>>(),
        "whisper_url": settings.whisper.url,
        "ollama_url": settings.ollama.url,
    }))
}
