2025-06-05 07:45:16 +00:00

25 lines
582 B
Python

from fastapi import APIRouter, Depends
from sqlalchemy.orm import Session
from app.db.session import get_db
router = APIRouter()
@router.get("/health", tags=["Health"])
def health_check(db: Session = Depends(get_db)):
"""
Health check endpoint to verify if the API is up and running.
Also checks database connectivity.
"""
try:
# Verify database connection
db.execute("SELECT 1")
db_status = "healthy"
except Exception:
db_status = "unhealthy"
return {
"status": "healthy",
"database": db_status
}