"""Health endpoints: /healthz (liveness) and /readyz (readiness).""" from __future__ import annotations from fastapi import APIRouter from sqlalchemy import text from src.contract_check.api.deps import AsyncSessionDep router = APIRouter(tags=["health"]) @router.get("/healthz") async def healthz() -> dict[str, str]: return {"status": "ok"} @router.get("/readyz") async def readyz(session: AsyncSessionDep) -> dict[str, str]: try: # Deliberate raw SQL: lightweight connection/statement round-trip ping. await session.execute(text("SELECT 1")) except Exception as exc: return {"status": "not_ready", "reason": f"db: {exc}"} return {"status": "ok"}