from fastapi import APIRouter, Depends from sqlalchemy.orm import Session from pydantic import BaseModel from app.api import deps router = APIRouter() class HealthCheck(BaseModel): status: str db_connection: bool @router.get("", response_model=HealthCheck) def health_check(db: Session = Depends(deps.get_db)): """ Check the health of the application. """ # Check database connection try: # Try to execute a simple query to verify connection db.execute("SELECT 1") db_connection = True except Exception: db_connection = False return { "status": "ok" if db_connection else "error", "db_connection": db_connection }