26 lines
643 B
Python
26 lines
643 B
Python
from fastapi import APIRouter, Depends
|
|
from sqlalchemy import text
|
|
from sqlalchemy.orm import Session
|
|
|
|
from app.api.deps import db_dependency
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("/health")
|
|
def health_check(db: Session = Depends(db_dependency)):
|
|
"""
|
|
Health check endpoint to verify the API and database are working properly.
|
|
"""
|
|
try:
|
|
# Test database connection
|
|
db.execute(text("SELECT 1"))
|
|
db_status = "healthy"
|
|
except Exception:
|
|
db_status = "unhealthy"
|
|
|
|
return {
|
|
"status": "ok" if db_status == "healthy" else "error",
|
|
"api": "healthy",
|
|
"database": db_status
|
|
} |