from fastapi import APIRouter, Depends from sqlalchemy.orm import Session from app.database import get_db router = APIRouter() @router.get("/health", summary="Check service health") def health(db: Session = Depends(get_db)): """ Checks the health of the service. Returns: dict: A dictionary with the status of the service components """ # Check database connection try: # Execute a simple query to verify database connection db.execute("SELECT 1") db_status = "healthy" except Exception as e: db_status = f"unhealthy: {str(e)}" return { "status": "ok", "components": { "api": "healthy", "database": db_status } }