from __future__ import annotations from fastapi import APIRouter, Depends from fastapi.responses import JSONResponse from server.ai import get_daily_motivation, get_roast_of_the_day from server.auth import require_auth from server.config_loader import load_meds_config from server.db import get_db router = APIRouter(prefix="/api", tags=["content"]) NO_STORE = {"Cache-Control": "no-store"} @router.get("/roast") async def get_roast(_: dict = Depends(require_auth)) -> JSONResponse: config = load_meds_config() db = await get_db() try: data = await get_roast_of_the_day(db, config.timezone) finally: await db.close() return JSONResponse(data, headers=NO_STORE) @router.get("/motivation") async def get_motivation(_: dict = Depends(require_auth)) -> JSONResponse: config = load_meds_config() db = await get_db() try: data = await get_daily_motivation(db, config.timezone) finally: await db.close() return JSONResponse(data, headers=NO_STORE)