from fastapi import APIRouter, Depends, status from sqlalchemy.orm import Session from app.core.database import get_db router = APIRouter() @router.get("/health", status_code=status.HTTP_200_OK, tags=["Health"]) def health_check(db: Session = Depends(get_db)): """ Check the health of the API. Returns: dict: Status information about the API and its dependencies """ # Check database connection try: # Just execute a simple query db.execute("SELECT 1") db_status = "healthy" except Exception as e: db_status = f"unhealthy: {str(e)}" return { "status": "online", "api_version": "1.0", "dependencies": { "database": db_status } }