from fastapi import APIRouter, Depends from sqlalchemy.orm import Session from app.db.session import get_db router = APIRouter() @router.get("/health") def health_check(db: Session = Depends(get_db)): """ Health check endpoint. Returns: dict: Status indicating the health of the application and its dependencies """ # Check database connection try: # Execute a simple query to check DB connection db.execute("SELECT 1") db_status = "healthy" except Exception as e: db_status = f"unhealthy: {str(e)}" return { "status": "up", "database": db_status, }