File size: 1,355 Bytes
9002555
d57efd6
 
 
 
 
 
 
 
 
 
 
 
9002555
 
 
d57efd6
9002555
 
 
 
d57efd6
9002555
 
 
0767396
9002555
 
 
 
 
 
d57efd6
9002555
 
 
 
 
 
d57efd6
 
 
 
 
 
 
9002555
 
 
 
0767396
9002555
 
 
d57efd6
 
 
 
 
9002555
 
 
d57efd6
738d903
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from fastapi.applications import FastAPI
from api.router import (
    health,
    user,
    trial,
    role,
    book,
    book_collection,
    category,
    bot_general,
    bot_specific,
    bot_one
)
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(category.router)
    app.include_router(book.router)
    app.include_router(book_collection.router)
    app.include_router(bot_general.router)
    app.include_router(bot_specific.router)
    app.include_router(bot_one.router)
    app.include_router(trial.router) 
    app.include_router(role.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()