from typing import Any from litestar import Litestar from litestar.contrib.repository.exceptions import ( RepositoryError as RepositoryException, ) from litestar.openapi import OpenAPIConfig from app.controllers import create_router from app.lib import exceptions, sqlalchemy_plugin from app.lib.service import ServiceError def create_app(**kwargs: Any) -> Litestar: return Litestar( route_handlers=[create_router()], openapi_config=OpenAPIConfig(title="My API", version="1.0.0"), # dependencies={"session": provide_transaction}, plugins=[sqlalchemy_plugin.plugin], exception_handlers={ RepositoryException: exceptions.repository_exception_to_http_response, # type: ignore[dict-item] ServiceError: exceptions.service_exception_to_http_response, # type: ignore[dict-item] }, debug=True, **kwargs, ) app = create_app()