-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
34 lines (28 loc) · 1011 Bytes
/
main.py
File metadata and controls
34 lines (28 loc) · 1011 Bytes
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
from fastapi import FastAPI
from fastapi.exceptions import RequestValidationError, HTTPException
from starlette.middleware.cors import CORSMiddleware
from src.api import (
authentication_endpoint,
countries_endpoint,
)
from src.exception.exception_handler import (
validation_exception_handler,
custom_http_exception_handler,
general_exception_handler,
)
from src.middleware.request_middleware import RequestIDMiddleware
app = FastAPI()
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
app.add_middleware(RequestIDMiddleware)
app.add_exception_handler(RequestValidationError, validation_exception_handler)
app.add_exception_handler(HTTPException, custom_http_exception_handler)
app.add_exception_handler(Exception, general_exception_handler)
app.include_router(authentication_endpoint.router)
app.include_router(countries_endpoint.router)
# app.include_router(google_auth_endpoint.router)