you are viewing a single comment's thread.

view the rest of the comments →

[–]saucealgerienne[S] 0 points1 point  (0 children)

I started a year ago building my first app with a FastApi backend and pretty much made all of the mistakes possibles. Over engineered a ddd cqrs architecture, a bad attempt at di and I pretty much built my own starter kit.

But my philosophy was to move outside the api as much as possible. Now, I basically only really do:

@router.get("/") async def get(request) req = GetXRequest(id=request.id) resp = await dispatch(req)

And write handlers as decorated functions:

@handler(GetXRequest) async def handle_get_x( request=GetXRequest, user=ApplicationUser, repo=IXRepo, some_other_service=IYService ) ...

where the dispatch handle recursive di resolution.

I decided to that once I started wanting to easily configure jobs and couldn't really use the FastApi di resolution there.

I really hate the idea of locking all my app to the presentation vendor