Files
takeyourmeds/server/api/stats.py
T
Frank Schwenk 88bdf6f34b feat: overhaul with modular API, agent endpoints, migrations, backup and tests
- Split monolithic app.py into server/api/ routers
- Add Pydantic schemas for input validation
- Add /agent/* API with separate AGENT_TOKEN auth
- Replace static schema.sql with versioned migrations (datenerhaltend)
- Add tools/backup_db.py for SQLite backups
- Add Dockerfile HEALTHCHECK and compose.yml AGENT_TOKEN env
- Add pytest tests for user and agent API
- Update README with API docs and deployment safety notes
- Bump version to 1.2.0
2026-09-21 12:46:44 +02:00

23 lines
572 B
Python

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)