use APIRouter instead of another FastAPI

This commit is contained in:
Jörn-Michael Miehe 2022-03-24 23:44:51 +00:00
parent c0e21315e7
commit c117698e48
2 changed files with 13 additions and 8 deletions

View file

@ -15,13 +15,12 @@ from fastapi import FastAPI
from .config import Config, Settings
from .db import Connection
from .db.schemas import User
from .routers import admin, dn, user
from .routers import main_router
settings = Settings.get()
app = FastAPI()
api = FastAPI(
app = FastAPI(
title="kiwi-vpn API",
description="This API enables the `kiwi-vpn` service.",
contact={
@ -37,11 +36,7 @@ api = FastAPI(
redoc_url=settings.redoc_url if not settings.production_mode else None,
)
api.include_router(admin.router)
api.include_router(user.router)
api.include_router(dn.router)
app.mount("/api", api)
app.include_router(main_router)
@app.on_event("startup")

View file

@ -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"]