Initializing multitenant
This commit is contained in:
@@ -1,19 +1,20 @@
|
||||
from contextlib import asynccontextmanager
|
||||
from fastapi import FastAPI
|
||||
|
||||
from .contract import contract_router
|
||||
from .db import init_db
|
||||
#from .contract import contract_router
|
||||
from .db import init_db, stop_db
|
||||
from .user import user_router, get_auth_router
|
||||
from .entity import entity_router
|
||||
from .template import template_router
|
||||
# from .order import order_router
|
||||
|
||||
app = FastAPI(root_path="/api/v1")
|
||||
#from .template import template_router
|
||||
|
||||
|
||||
@app.on_event("startup")
|
||||
async def on_startup():
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI):
|
||||
await init_db()
|
||||
yield
|
||||
await stop_db()
|
||||
|
||||
app = FastAPI(root_path="/api/v1", lifespan=lifespan)
|
||||
|
||||
app.include_router(get_auth_router(), prefix="/auth", tags=["auth"], )
|
||||
app.include_router(user_router, prefix="/users", tags=["users"], )
|
||||
@@ -21,8 +22,8 @@ app.include_router(user_router, prefix="/users", tags=["users"], )
|
||||
multitenant_prefix = "/{instance}/{firm}"
|
||||
|
||||
app.include_router(entity_router, prefix=f"{multitenant_prefix}/entity", tags=["entity"], )
|
||||
app.include_router(template_router, prefix=f"{multitenant_prefix}/template", tags=["template"], )
|
||||
app.include_router(contract_router, prefix=f"{multitenant_prefix}/contract", tags=["contract"], )
|
||||
#app.include_router(template_router, prefix=f"{multitenant_prefix}/template", tags=["template"], )
|
||||
#app.include_router(contract_router, prefix=f"{multitenant_prefix}/contract", tags=["contract"], )
|
||||
|
||||
if __name__ == '__main__':
|
||||
import uvicorn
|
||||
|
||||
Reference in New Issue
Block a user