use crate::{error::Result, state::AppState};
use axum::{extract::State, response::IntoResponse};
use lmrc_http_common::health::{CheckResult, HealthStatus};
pub async fn health_check(State(state): State<AppState>) -> Result<impl IntoResponse> {
let mut health = HealthStatus::new(env!("CARGO_PKG_VERSION"));
let db_check = match state.db.ping().await {
Ok(_) => CheckResult::healthy_with_message("Database connected"),
Err(e) => CheckResult::unhealthy(format!("Database error: {}", e)),
};
health = health.with_check("database", db_check);
Ok(health)
}