app.py 606 B

12345678910111213141516171819
  1. from fastapi import FastAPI
  2. from app.api.routes import router
  3. from app.bootstrap.settings import ApiGatewaySettings
  4. from app.db.session import build_session_factory
  5. from app.infrastructure.request_context import GatewayRequestContextMiddleware
  6. def create_app() -> FastAPI:
  7. settings = ApiGatewaySettings()
  8. app = FastAPI(
  9. title="agent-platform api-gateway",
  10. version="0.1.0",
  11. )
  12. app.state.settings = settings
  13. app.state.session_factory = build_session_factory(settings)
  14. app.add_middleware(GatewayRequestContextMiddleware)
  15. app.include_router(router)
  16. return app