30 lines
743 B
Python
30 lines
743 B
Python
from typing import Dict
|
|
|
|
from fastapi import APIRouter, Depends
|
|
from sqlalchemy.orm import Session
|
|
|
|
from app.api import deps
|
|
from app.db.session import engine
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("/health", response_model=Dict[str, str])
|
|
def health_check(db: Session = Depends(deps.get_db)) -> Dict[str, str]:
|
|
"""
|
|
Health check endpoint.
|
|
|
|
Checks database connection and returns service status.
|
|
"""
|
|
try:
|
|
# Try to execute a simple query to verify db connection
|
|
with engine.connect() as connection:
|
|
connection.execute("SELECT 1")
|
|
db_status = "healthy"
|
|
except Exception:
|
|
db_status = "unhealthy"
|
|
|
|
return {
|
|
"status": "healthy",
|
|
"database": db_status
|
|
} |