signebedi / libreforms-fastapi

FastAPI implementation of the libreForms spec
GNU Affero General Public License v3.0
1 stars 1 forks source link

Reduce boilerplate in endpoints #149

Open signebedi opened 3 months ago

signebedi commented 3 months ago

There is a lot of boilerplate in app/__init__.py right now. We should think about ways to reduce it.

signebedi commented 2 months ago

One question: can we use a blueprint approach like in flask? Potentially useful: https://fastapi.tiangolo.com/reference/apirouter/.

signebedi commented 1 month ago

So this will look something like having separate scripts for ui_form, ui_auth, ui_admin; api_form, api_auth, and api_admin.

Each of these can include an API router:

from fastapi import  APIRouter

my_router = APIRouter()
@router.get(...)

And then, in init.py, we can add these routes:

from libreforms_fastapi.app.routes.api_form import my_router

app.include_router(my_router)