31 lines
742 B
Python
31 lines
742 B
Python
"""Health check endpoints."""
|
|
from fastapi import APIRouter
|
|
|
|
from app.database import DatabaseService
|
|
from app.logging import get_logger
|
|
|
|
router = APIRouter()
|
|
logger = get_logger(__name__)
|
|
|
|
|
|
@router.get("/health-check")
|
|
async def health_check() -> dict[str, str]:
|
|
"""Comprehensive health check endpoint."""
|
|
|
|
# Check database connectivity
|
|
try:
|
|
db_healthy = DatabaseService.health_check()
|
|
except Exception as e:
|
|
logger.error("Database health check failed", exc_info=e)
|
|
db_healthy = False
|
|
|
|
status = "healthy" if db_healthy else "unhealthy"
|
|
|
|
result = {
|
|
"status": status,
|
|
"service": "loapi",
|
|
"database": "connected" if db_healthy else "disconnected"
|
|
}
|
|
|
|
return result
|