feat(presentation): GET /health endpoint
This commit is contained in:
10
crates/presentation/src/handlers/health.rs
Normal file
10
crates/presentation/src/handlers/health.rs
Normal 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" },
|
||||||
|
}))
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
pub mod api_keys;
|
pub mod api_keys;
|
||||||
pub mod auth;
|
pub mod auth;
|
||||||
pub mod feed;
|
pub mod feed;
|
||||||
|
pub mod health;
|
||||||
pub mod notifications;
|
pub mod notifications;
|
||||||
pub mod social;
|
pub mod social;
|
||||||
pub mod thoughts;
|
pub mod thoughts;
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ use crate::{handlers::*, state::AppState};
|
|||||||
|
|
||||||
pub fn router(fed_config: &ApFederationConfig) -> Router<AppState> {
|
pub fn router(fed_config: &ApFederationConfig) -> Router<AppState> {
|
||||||
let api_routes = Router::new()
|
let api_routes = Router::new()
|
||||||
|
// health
|
||||||
|
.route("/health", get(health::health_handler))
|
||||||
// auth
|
// auth
|
||||||
.route("/auth/register", post(auth::post_register))
|
.route("/auth/register", post(auth::post_register))
|
||||||
.route("/auth/login", post(auth::post_login))
|
.route("/auth/login", post(auth::post_login))
|
||||||
|
|||||||
Reference in New Issue
Block a user