"""FastAPI application assembly.""" from __future__ import annotations import logging from contextlib import asynccontextmanager from fastapi import FastAPI from gogo.api import actions, health, webhooks from gogo.config import get_settings logging.basicConfig( level=logging.INFO, format="%(asctime)s %(levelname)s %(name)s %(message)s" ) @asynccontextmanager async def lifespan(app: FastAPI): scheduler = None if get_settings().env != "test": from gogo.jobs import build_scheduler scheduler = build_scheduler() scheduler.start() yield if scheduler: scheduler.shutdown(wait=False) def create_app() -> FastAPI: app = FastAPI(title="Gogo Telefon", docs_url=None, redoc_url=None, lifespan=lifespan) app.include_router(health.router) app.include_router(actions.router) app.include_router(webhooks.router) return app app = create_app()