fooder-api/fooder/view/preset.py

20 lines
519 B
Python
Raw Normal View History

2023-10-27 15:12:48 +02:00
from fastapi import APIRouter, Depends, Request
from ..model.preset import ListPresetsPayload
from ..controller.preset import ListPresets
router = APIRouter(tags=["preset"])
@router.get("", response_model=ListPresetsPayload)
async def list_presets(
request: Request,
limit: int = 10,
offset: int = 0,
q: str | None = None,
controller: ListPresets = Depends(ListPresets),
):
return ListPresetsPayload(
presets=[p async for p in controller.call(limit=limit, offset=offset, q=q)]
)