51 lines
1.2 KiB
Python
51 lines
1.2 KiB
Python
"""Health check routes."""
|
|
|
|
from fastapi import APIRouter, Depends
|
|
from sqlalchemy.orm import Session
|
|
from sqlalchemy import text
|
|
from request_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)
|
|
}
|
|
|
|
|
|
@router.get("/module/info")
|
|
async def module_info():
|
|
"""Return module metadata for platform registration."""
|
|
return {
|
|
"id": "request",
|
|
"name": "Request Management",
|
|
"version": "1.0.0",
|
|
"frontend": {
|
|
"dev_url": "http://localhost:5174",
|
|
"prod_path": "/modules/request",
|
|
}
|
|
}
|