From bacd49468b3312a43201969895a1bcb85a1633a3 Mon Sep 17 00:00:00 2001 From: nhucuc9999 Date: Tue, 17 Mar 2026 13:47:51 +0700 Subject: [PATCH] feat: add public health check endpoint Add GET /health endpoint (no auth required) returning backend_running status and has_active_tokens boolean for uptime monitoring. --- src/api/admin.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/api/admin.py b/src/api/admin.py index a49b864..719c6b0 100644 --- a/src/api/admin.py +++ b/src/api/admin.py @@ -1102,6 +1102,17 @@ async def logout(token: str = Depends(verify_admin_token)): return await admin_logout(token) +@router.get("/health") +async def health_check(): + """Public health check endpoint - no auth required""" + try: + stats = await db.get_dashboard_stats() + has_active_tokens = stats.get("active_tokens", 0) > 0 + except Exception: + return {"backend_running": True, "has_active_tokens": False} + return {"backend_running": True, "has_active_tokens": has_active_tokens} + + @router.get("/api/stats") async def get_stats(token: str = Depends(verify_admin_token)): """Get statistics for dashboard"""