37 lines
888 B
Python
37 lines
888 B
Python
"""Health check routes."""
|
|
|
|
from fastapi import APIRouter, Depends
|
|
from sqlalchemy.orm import Session
|
|
from sqlalchemy import text
|
|
from app.core.database import get_db
|
|
|
|
router = APIRouter(tags=["Health"])
|
|
|
|
|
|
@router.get("/health")
|
|
async def health_check():
|
|
"""Health check endpoint."""
|
|
return {
|
|
"status": "healthy",
|
|
"service": "Service Request System",
|
|
"version": "1.0.0"
|
|
}
|
|
|
|
|
|
@router.get("/health/db")
|
|
async def health_check_db(db: Session = Depends(get_db)):
|
|
"""Check database connectivity."""
|
|
try:
|
|
db.execute(text("SELECT 1"))
|
|
return {
|
|
"status": "healthy",
|
|
"database": "PostgreSQL",
|
|
"message": "Database connection successful"
|
|
}
|
|
except Exception as e:
|
|
return {
|
|
"status": "unhealthy",
|
|
"database": "PostgreSQL",
|
|
"error": str(e)
|
|
}
|