-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
51 lines (39 loc) · 1.79 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
"""Main module for running shopapi server
"""
import logging
from fastapi import FastAPI
from tortoise.contrib.fastapi import register_tortoise
from shopapi import routers
from shopapi.config import build_db_url
# TODO: Logging from config to keep everything in one place?
logging.basicConfig(format="[%(asctime)s] <%(name)s> %(levelname)s: %(message)s", level=logging.INFO)
logger = logging.getLogger(__name__)
tags = [
{"name": "General", "description": "Generic endpoints that belong nowhere else."},
{"name": "Authentication", "description": "Authenticate user, create openid and manage openid associations."},
{"name": "Users", "description": "Endpoints used to manage users and role associations."},
{"name": "Roles", "description": "Endpoints used to manage user roles"},
{"name": "Categories", "description": "Categories allow basic products differentiation."},
{"name": "Tags", "description": "Tags allow better products and categories sub-categorization."},
{"name": "Service", "description": "Service endpoint used to manager ShopAPI environment and deployment."},
]
app = FastAPI(
# redoc_url=None,
title="ShopAPI",
description="Made possible with `FastAPI`, `tortoise-orm` and many others",
openapi_tags=tags,
)
@app.get("/", tags=["General"], name="The Room Easter Egg")
def index():
"""> I did not hit her, I did not.
>
> -- <cite>Tommy</cite>
"""
return {"message": "Oh, hi, Mark!"}
app.include_router(routers.auth.router)
app.include_router(routers.user.router)
app.include_router(routers.service.router)
app.include_router(routers.role.router)
app.include_router(routers.tag.router)
app.include_router(routers.category.router)
register_tortoise(app, db_url=build_db_url(), modules={"models": ["shopapi.schemas.models"]}, generate_schemas=True)