-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
41 lines (30 loc) · 918 Bytes
/
main.py
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
from fastapi import FastAPI, Request
from fastapi.responses import JSONResponse
from fastapi.middleware.cors import CORSMiddleware
from mangum import Mangum
from balancelib.interactors.response_api_interactor import ResponseError
from balancelib.routes import (
user_routes,
bank_routes,
nubank_routes,
)
from database.settings import create_tables
create_tables()
app = FastAPI(app_name="balance")
@app.exception_handler(ResponseError)
async def unicorn_exception_handler(request: Request, exc: ResponseError):
return JSONResponse(
status_code=exc.status_code,
content=exc.error(),
)
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
app.include_router(user_routes.router)
app.include_router(bank_routes.router)
app.include_router(nubank_routes.router)
handler = Mangum(app)