29 lines
642 B
Python
29 lines
642 B
Python
from fastapi import APIRouter, Depends
|
|
from sqlalchemy.orm import Session
|
|
from sqlalchemy import text
|
|
|
|
from app.db.session import get_db
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("/health")
|
|
def health_check(db: Session = Depends(get_db)):
|
|
"""
|
|
Health check endpoint.
|
|
|
|
Returns:
|
|
dict: Status of the service and its dependencies.
|
|
"""
|
|
# Check database connectivity
|
|
try:
|
|
db.execute(text("SELECT 1"))
|
|
db_status = "healthy"
|
|
except Exception as e:
|
|
db_status = f"unhealthy: {str(e)}"
|
|
|
|
return {
|
|
"status": "healthy",
|
|
"database": db_status,
|
|
"version": "0.1.0"
|
|
} |