-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
55 lines (47 loc) · 1.52 KB
/
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from fastapi import FastAPI
from fastapi.responses import JSONResponse
import metadata
from config import Config
from customizer import http_customize_handler, validation_body_exception_handler
from endpoint.auth import routes as auth_routes
from endpoint.nutrition import routes as nutrition_routes
from endpoint.settings import routes as settings_routes
from service.authentication import AuthService
from service.nutrition import NutritionService
from service.settings import SettingsService
config = Config()
# service
auth_service = AuthService(
app=config.firebase_app, api_key=config.api_key, db=config.firestore_app
)
nutrition_service = NutritionService(
app=config.firebase_app,
storage=config.storage,
db=config.firestore_app,
ml=config.ml,
)
settings_service = SettingsService(
app=config.firebase_app,
storage=config.storage,
db=config.firestore_app,
api_key=config.api_key,
auth_service=auth_service,
)
# router
app = FastAPI(
title=metadata.title,
description=metadata.description,
version=metadata.version,
contact=metadata.contact,
license_info=metadata.license_info,
openapi_tags=metadata.tags_metadata,
debug=True,
)
validation_body_exception_handler(app)
http_customize_handler(app)
app.include_router(auth_routes(auth_service))
app.include_router(nutrition_routes(nutrition_service))
app.include_router(settings_routes(settings_service))
@app.get("/")
async def index() -> JSONResponse:
return JSONResponse(status_code=200, content={"code": 200, "msg": "OK"})