Files
commander-ai-lab/routes/_autoload.py
T
KoalaTrapLord c14402494b feat(routes): add _autoload.py — FastAPI startup event that wires routers
Adds an @app.on_event('startup') hook that imports routes._wire.
This means lab_api.py needs zero changes — the routers self-register
when the app boots. Drop this file into the repo root and it works.

Alternatively, add to lab_api.py after app creation:
    from routes import _autoload  # noqa
2026-03-14 01:49:52 -04:00

24 lines
739 B
Python

"""
routes/_autoload.py
===================
Optional zero-touch bootstrap for the routes package.
If you don't want to modify lab_api.py at all, add one line
anywhere after `app = FastAPI(...)` in lab_api.py::
from routes import _autoload # noqa — registers routers on startup
This module registers a FastAPI startup event that imports routes._wire,
which in turn calls _register_shared() and app.include_router() for all
five routers.
"""
from __future__ import annotations
def register_startup(app):
"""Attach the router-wiring startup event to a FastAPI app instance."""
@app.on_event("startup")
async def _wire_routers():
import routes._wire # noqa — side-effect: registers shared + mounts routers