Basic users and cities api
This commit is contained in:
28
main.py
Normal file
28
main.py
Normal file
@ -0,0 +1,28 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user