From c117698e48c843227d344e8e1fea6e3b958e3988 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= <40151420+ldericher@users.noreply.github.com> Date: Thu, 24 Mar 2022 23:44:51 +0000 Subject: [PATCH] use APIRouter instead of another FastAPI --- api/kiwi_vpn_api/main.py | 11 +++-------- api/kiwi_vpn_api/routers/__init__.py | 10 ++++++++++ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/api/kiwi_vpn_api/main.py b/api/kiwi_vpn_api/main.py index 399ce0f..82c2fa8 100755 --- a/api/kiwi_vpn_api/main.py +++ b/api/kiwi_vpn_api/main.py @@ -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") diff --git a/api/kiwi_vpn_api/routers/__init__.py b/api/kiwi_vpn_api/routers/__init__.py index e69de29..22bb142 100644 --- a/api/kiwi_vpn_api/routers/__init__.py +++ b/api/kiwi_vpn_api/routers/__init__.py @@ -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"]