2025-06-04 22:37:35 +00:00

29 lines
681 B
Python

from typing import Any, Dict
from fastapi import APIRouter, Depends
from sqlalchemy.orm import Session
from app.core.config import settings
from app.db.session import get_db
router = APIRouter()
@router.get("/", response_model=Dict[str, Any])
async def health_check(db: Session = Depends(get_db)) -> Any:
"""
Check API health.
"""
# Check if database connection is working
db_status = "healthy"
try:
# Try executing a simple query
db.execute("SELECT 1")
except Exception:
db_status = "unhealthy"
return {
"status": "healthy",
"version": settings.PROJECT_VERSION,
"database": db_status,
}