from fastapi import APIRouter from pydantic import BaseModel from app.config import get_settings from app.db import check_db class HealthResponse(BaseModel): role: str db: str image_sha: str router = APIRouter() def _build(role: str, db_ok: bool) -> HealthResponse: return HealthResponse( role=role, db="ok" if db_ok else "fail", image_sha=get_settings().app_git_sha, ) @router.get("/health/gateway") async def health_gateway() -> HealthResponse: return _build("gateway", await check_db()) @router.get("/health/worker") async def health_worker() -> HealthResponse: return _build("worker", await check_db()) @router.get("/health/cron") async def health_cron() -> HealthResponse: return _build("cron", await check_db())