Esempio n. 1
0
def main() -> None:
    from uvicorn import run  # pylint: disable=C0415

    run(
        app='main:app',
        host=env(key='http_host', typ=str),
        port=env(key='http_port', typ=int),
        log_level=env(key='log_level', typ=str).lower(),  # type: ignore
        reload=debug,
    )  # pragma: no cover
 def setup(self) -> None:
     self._cnf = EmailConfig(
         host=env('email_host', typ=str),
         port=env('email_port', typ=int),
         host_user=env('email_host_user', typ=str),
         host_password=env('email_host_password', typ=str),
         use_tls=env('email_use_tls', typ=bool),
         from_user=env('email_from', typ=str),
     )
     self._email_ui_port = env('email_ui_port', typ=int)
     self._sut = EmailUserNotifier(config=self._cnf)
Esempio n. 3
0
 async def _drop_mongodb_database() -> None:
     container().get(MongoDBConnection).client().drop_database(
         env(key='mongodb_database', typ=str))
Esempio n. 4
0
from aiocli.commander import Application, run_app

from project.apps.cli.controllers.example.example_router import example_router
from project.apps.settings import container, env

app = Application(
    debug=env(key='debug', typ=bool),
    title=env(key='name', typ=str),
    version=env(key='version', typ=str),
    default_exit_code=1,
    on_startup=[lambda _: container()],  # to avoid event_loop issues with third parties
    on_shutdown=[lambda _: container().get('services.shutdown')()],
)

app.include_router(example_router)


def main() -> None:
    run_app(app=app)
Esempio n. 5
0
from fastapi import APIRouter, FastAPI
from fastapi.exceptions import RequestValidationError
from fastapi.responses import ORJSONResponse
from starlette.exceptions import HTTPException
from starlette.middleware.cors import CORSMiddleware

from project.apps.api.controllers import (
    private_users,
    protected_users,
    public_global,
    public_users,
)
from project.apps.api.middleware.exception_handler import APIErrors, exception_handler
from project.apps.settings import container, env

debug = env(key='debug', typ=bool)

app = FastAPI(
    debug=debug,
    default_response_class=ORJSONResponse,  # better performance
    openapi_url=env(key="openapi_url", typ=str),
    openapi_prefix=env(key="openapi_prefix", typ=str),
    docs_url='/api/docs',
    redoc_url='/api/redoc',
    title=env(key='name', typ=str),
    version=env(key='version', typ=str),
    on_startup=[container],  # to avoid event_loop issues with third parties
    on_shutdown=[lambda: container().get('services.shutdown')()],
)