"""Public (internet-facing) routes. For PR 1: only ``/health``. The webhook receiver and renewal portal land in PR 2 and PR 3 respectively. """ from __future__ import annotations from fastapi import APIRouter, Depends from sqlalchemy import text from sqlalchemy.exc import SQLAlchemyError from sqlalchemy.orm import Session from app.db import get_session router = APIRouter() @router.get("/health") def health(session: Session = Depends(get_session)) -> dict: """Liveness + DB reachability. Cheap; safe to hit on a tight cadence.""" db_ok = True try: session.execute(text("SELECT 1")) except SQLAlchemyError: db_ok = False return {"status": "ok" if db_ok else "degraded", "db": "ok" if db_ok else "error"}