{'src': {'__init__.py': '', 'application': {'__init__.py': ''}, 'delivery': {'__init__.py': '', 'api': {'__init__.py': '', 'application.py': 'from fastapi import FastAPI, Request\nfrom fastapi.responses import JSONResponse\n\nfrom src.api.lifespan\n\napp = FastAPI(lifespan=lifespan)\n\n@app.exception_handler(Exception)\nasync def unexpected_exception_handler(_: Request, exc: Exception) -> JSONResponse:\n\treturn HttpResponse.internal_error(exc)\n\n\n@app.exception_handler(DomainError)\nasync def domain_error_handler(_: Request, exc: DomainError) -> JSONResponse:\n\treturn HttpResponse.domain_error(exc, status_code=StatusCode.BAD_REQUEST)', 'lifespan.py': 'from collections.abc import AsyncGenerator\nfrom contextlib import asynccontextmanager\n\nfrom fastapi import FastAPI\n\n\n@asynccontextmanager\nasync def lifespan(_: FastAPI) -> AsyncGenerator[None, None]:\n\tmigrator = AlembicMigrator()\n\tawait migrator.migrate()\n\tyield'}}, 'infra': {'__init__.py': '', 'alembic_migrator.py': 'import asyncio\n\nfrom alembic import command\nfrom alembic.config import Config\n\n\nclass AlembicMigrator:\n\tdef __init__(self) -> None:\n\t\tself._settings = PostgresSettings()  # type: ignore\n\t\tself._alembic_config = Config()\n\n\tasync def migrate(self) -> None:\n\t\tself._alembic_config.set_main_option(\n\t\t\t"sqlalchemy.url", self._settings.postgres_url\n\t\t)\n\t\tself._alembic_config.set_main_option("script_location", "migrations")\n\t\tloop = asyncio.get_event_loop()\n\t\tawait loop.run_in_executor(None, command.upgrade, self._alembic_config, "head")  # type: ignore', 'http': {'__init__.py': '', 'http_response.py': 'from fastapi.responses import JSONResponse\n\n\nclass HttpResponse:\n\t@staticmethod\n\tdef domain_error(error: DomainError, status_code: StatusCode) -> JSONResponse:\n\t\treturn JSONResponse(content={"error": error.to_primitives()}, status_code=status_code)\n\n\t@staticmethod\n\tdef internal_error(error: Exception) -> JSONResponse:\n\t\treturn JSONResponse(\n\t\t\tcontent={"error": "Internal server error"},\n\t\t\tstatus_code=StatusCode.INTERNAL_SERVER_ERROR,\n\t\t)\n\n\t@staticmethod\n\tdef created(resource: str) -> JSONResponse:\n\t\treturn JSONResponse(content={"resource": resource}, status_code=StatusCode.CREATED)\n\n\t@staticmethod\n\tdef ok(content: dict) -> JSONResponse:\n\t\treturn JSONResponse(content=content, status_code=StatusCode.OK)\n'}}}}
