27 lines
641 B
Python
27 lines
641 B
Python
from fastapi import APIRouter, Depends
|
|
from sqlalchemy.orm import Session
|
|
from sqlalchemy import text
|
|
from datetime import datetime
|
|
|
|
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
|
|
"""
|
|
try:
|
|
# Check database connection
|
|
db.execute(text("SELECT 1"))
|
|
db.commit()
|
|
db_status = "healthy"
|
|
except Exception as e:
|
|
db_status = f"unhealthy: {str(e)}"
|
|
|
|
return {
|
|
"status": "healthy",
|
|
"timestamp": datetime.utcnow(),
|
|
"database": db_status
|
|
} |