use APIRouter instead of another FastAPI
This commit is contained in:
parent
c0e21315e7
commit
c117698e48
2 changed files with 13 additions and 8 deletions
|
@ -15,13 +15,12 @@ from fastapi import FastAPI
|
||||||
from .config import Config, Settings
|
from .config import Config, Settings
|
||||||
from .db import Connection
|
from .db import Connection
|
||||||
from .db.schemas import User
|
from .db.schemas import User
|
||||||
from .routers import admin, dn, user
|
from .routers import main_router
|
||||||
|
|
||||||
settings = Settings.get()
|
settings = Settings.get()
|
||||||
|
|
||||||
app = FastAPI()
|
|
||||||
|
|
||||||
api = FastAPI(
|
app = FastAPI(
|
||||||
title="kiwi-vpn API",
|
title="kiwi-vpn API",
|
||||||
description="This API enables the `kiwi-vpn` service.",
|
description="This API enables the `kiwi-vpn` service.",
|
||||||
contact={
|
contact={
|
||||||
|
@ -37,11 +36,7 @@ api = FastAPI(
|
||||||
redoc_url=settings.redoc_url if not settings.production_mode else None,
|
redoc_url=settings.redoc_url if not settings.production_mode else None,
|
||||||
)
|
)
|
||||||
|
|
||||||
api.include_router(admin.router)
|
app.include_router(main_router)
|
||||||
api.include_router(user.router)
|
|
||||||
api.include_router(dn.router)
|
|
||||||
|
|
||||||
app.mount("/api", api)
|
|
||||||
|
|
||||||
|
|
||||||
@app.on_event("startup")
|
@app.on_event("startup")
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
from fastapi import APIRouter
|
||||||
|
|
||||||
|
from . import admin, user
|
||||||
|
|
||||||
|
main_router = APIRouter(prefix="/api/v1")
|
||||||
|
|
||||||
|
main_router.include_router(admin.router)
|
||||||
|
main_router.include_router(user.router)
|
||||||
|
|
||||||
|
__all__ = ["main_router"]
|
Loading…
Reference in a new issue