38 lines
1010 B
Python
38 lines
1010 B
Python
from fastapi import FastAPI
|
|
from fastapi.routing import APIRoute
|
|
from starlette.middleware.cors import CORSMiddleware
|
|
|
|
from app.api import api_router
|
|
from app.core.config import settings
|
|
from app.utils import logger
|
|
|
|
logger.setup_logger()
|
|
|
|
|
|
def custom_generate_unique_id(route: APIRoute) -> str:
|
|
return f"{route.tags[0]}-{route.name}"
|
|
|
|
|
|
app = FastAPI(
|
|
title="SWAG Shop",
|
|
version="0.0.1",
|
|
generate_unique_id_function=custom_generate_unique_id,
|
|
openapi_tags=[
|
|
{"name": "Dashboard", "description": "Operations endpoints related the admin dashboard. Hidden in production"},
|
|
{"name": "Shop", "description": "Shop endpoints which include also user, product and other entity management"},
|
|
{"name": "Utils"},
|
|
]
|
|
)
|
|
|
|
|
|
if settings.all_cors_origins:
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=settings.all_cors_origins,
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
app.include_router(api_router)
|