{% include "templates/base/rate_limiting_health.py.j2" %}

from typing import Dict

from fastapi import APIRouter, FastAPI, status

from src.modules.free.security.rate_limiting import get_rate_limiter_metadata

router = APIRouter(prefix="/api/health/module", tags=["health"])


@router.get(
    "/rate-limiting",
    summary="Rate Limiting module health check",
    status_code=status.HTTP_200_OK,
)
async def rate_limiting_health_check() -> Dict[str, object]:
    """Return normalized metadata for the rate limiting subsystem."""

    metadata = get_rate_limiter_metadata()
    snapshot = build_health_snapshot(metadata, features=RATE_LIMITING_FEATURES)
    return render_health_snapshot(snapshot)


def register_rate_limiting_health(app: FastAPI) -> None:
    """Attach Rate Limiting health routes to a FastAPI application."""

    app.include_router(router)


__all__ = [
    "RATE_LIMITING_FEATURES",
    "build_health_snapshot",
    "render_health_snapshot",
    "build_metadata",
    "rate_limiting_health_check",
    "register_rate_limiting_health",
    "router",
]
