Bot_Development / app.py
dsmultimedika's picture
Update Repository
0743bb0
raw
history blame
1.09 kB
from fastapi.applications import FastAPI
from api.router import health, topic, user, bot, trial, role, reader
from fastapi.middleware.cors import CORSMiddleware
from api.events import register_events
from utils.utils import pipe
def create_instance() -> FastAPI:
return FastAPI()
def add_middleware(app: FastAPI) -> FastAPI:
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
return app
def init_database(app: FastAPI) -> FastAPI:
return app
def register_routers(app: FastAPI) -> FastAPI:
app.include_router(user.router)
app.include_router(topic.router)
app.include_router(bot.router)
app.include_router(trial.router)
app.include_router(role.router)
app.include_router(reader.router)
app.include_router(health.router)
return app
def init_app() -> FastAPI:
app: FastAPI = pipe(
create_instance(), add_middleware, init_database, register_events, register_routers
)
return app
app = init_app()