fastcbv
FastAPI declares an endpoint as a function, and everything the endpoint needs is declared in its signature. That is the right shape for one route. It stops being the right shape once several routes share the same authentication, the same database handle, and the same path parameter, because the shared part has nowhere to live and gets restated in every function that needs it.
A class is where that shared part already belongs. fastcbv binds a
view class to a route, dispatches each HTTP method to the method of
the same name, and reads class attributes annotated with
Depends as dependencies of every method on
the class. What was repeated per function is written once, and the
endpoints that differ are the only thing left in the body.
Path, query, and body parameters are declared in the method
signature and resolve exactly as FastAPI resolves them on a
function. A __prepare__ hook runs before
the dispatched method for setup the whole class shares, the request
is available as self.request, and views
inherit, so a base class can carry the dependencies and the hook
that a family of routes has in common.