// Health check endpoint

use axum::{http::StatusCode, response::IntoResponse, Json};
use ontoref_derive::onto_api;
use serde_json::json;

/// Health check endpoint
///
/// Returns current server status and version information
#[onto_api(
    method = "GET",
    path = "/health",
    description = "Returns current server liveness status and build version.",
    auth = "none",
    actors = "developer, agent, ci, admin",
    tags = "health, system"
)]
pub async fn health() -> impl IntoResponse {
    (
        StatusCode::OK,
        Json(json!({
            "status": "healthy",
            "service": "vapora-backend",
            "version": env!("CARGO_PKG_VERSION"),
            "timestamp": chrono::Utc::now().to_rfc3339(),
        })),
    )
}

#[cfg(test)]
mod tests {
    use super::*;

    #[tokio::test]
    async fn test_health_endpoint() {
        let _response = health().await;
        // Response type verification - actual testing will be in integration
        // tests
    }
}
