from fastapi import APIRouter, Depends, status from sqlalchemy.orm import Session from app.db.session import get_db router = APIRouter() @router.get("/", status_code=status.HTTP_200_OK) def health_check(db: Session = Depends(get_db)): """ Check the health of the API. """ try: # Validate database connection db.execute("SELECT 1") return { "status": "ok", "message": "API is healthy", "database": "connected" } except Exception as e: return { "status": "error", "message": "API health check failed", "database": "disconnected", "error": str(e) }