28 lines
686 B
Python
28 lines
686 B
Python
from fastapi import APIRouter, Depends, status
|
|
from sqlalchemy.orm import Session
|
|
from sqlalchemy import text
|
|
|
|
from app.core.config import settings
|
|
from app.db.deps import get_db
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("/health", status_code=status.HTTP_200_OK)
|
|
def health_check(db: Session = Depends(get_db)):
|
|
"""
|
|
Health check endpoint for the application.
|
|
"""
|
|
# Check database connection
|
|
try:
|
|
db.execute(text("SELECT 1"))
|
|
db_status = "healthy"
|
|
except Exception:
|
|
db_status = "unhealthy"
|
|
|
|
return {
|
|
"status": "healthy",
|
|
"app_name": settings.PROJECT_NAME,
|
|
"api_version": "v1",
|
|
"database": db_status
|
|
} |