feat(presentation): GET /health endpoint

This commit is contained in:
2026-05-14 11:21:58 +02:00
parent 6082766935
commit 2524440fe4
3 changed files with 13 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
use axum::{extract::State, Json};
use crate::state::AppState;
pub async fn health_handler(State(s): State<AppState>) -> Json<serde_json::Value> {
let db_ok = s.users.list_with_stats().await.is_ok();
Json(serde_json::json!({
"status": if db_ok { "ok" } else { "degraded" },
"db": if db_ok { "connected" } else { "error" },
}))
}

View File

@@ -1,6 +1,7 @@
pub mod api_keys;
pub mod auth;
pub mod feed;
pub mod health;
pub mod notifications;
pub mod social;
pub mod thoughts;

View File

@@ -16,6 +16,8 @@ use crate::{handlers::*, state::AppState};
pub fn router(fed_config: &ApFederationConfig) -> Router<AppState> {
let api_routes = Router::new()
// health
.route("/health", get(health::health_handler))
// auth
.route("/auth/register", post(auth::post_register))
.route("/auth/login", post(auth::post_login))