from __future__ import annotations from fastapi import APIRouter, Depends from fastapi.responses import JSONResponse from server.auth import require_auth from server.db import get_db from server.stats import compute_stats router = APIRouter(prefix="/api/stats", tags=["stats"]) NO_STORE = {"Cache-Control": "no-store"} @router.get("/") async def get_stats(_: dict = Depends(require_auth)) -> JSONResponse: db = await get_db() try: stats = await compute_stats(db) finally: await db.close() return JSONResponse(stats, headers=NO_STORE)