🩹 Fix FastAPI app initialization

This commit is contained in:
Brian Wiborg 2025-10-02 03:02:00 +02:00
parent ee4bd2760c
commit af110cec9d
No known key found for this signature in database

View file

@ -81,8 +81,8 @@ class Project:
# Attach routers from apps
for app_name, app_def in self._apps.items():
if app_def.router:
app.include_router(app_def.router)
for router in app_def.routers:
app.include_router(router)
# Startup / shutdown events
@app.on_event("startup")
@ -333,15 +333,22 @@ class App:
module: out,
}
@property
def routers(self):
out = []
for routes_mod in self._routers:
for r in self._routers[routes_mod]:
out.append(r)
return out
@property
def routes(self):
"""
Return an APIRouter with all loaded routes.
"""
router = APIRouter()
for routes_mod in self._routers:
for r in self._routers[routes_mod]:
router.include_router(r)
for r in self.routers:
router.include_router(r)
return router.routes
def dict(self) -> Dict[str, Any]: