From e078c7b09482a2e7e3be2d99b1b5975d1f231865 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= <40151420+ldericher@users.noreply.github.com> Date: Wed, 30 Mar 2022 10:53:36 +0000 Subject: [PATCH] minor refactoring --- api/kiwi_vpn_api/main.py | 10 ++++++---- api/kiwi_vpn_api/routers/__init__.py | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/api/kiwi_vpn_api/main.py b/api/kiwi_vpn_api/main.py index 86ae4f2..5583198 100755 --- a/api/kiwi_vpn_api/main.py +++ b/api/kiwi_vpn_api/main.py @@ -16,6 +16,8 @@ from .config import Config, Settings from .db import Connection, User from .routers import main_router +settings = Settings._ + app = FastAPI( title="kiwi-vpn API", description="This API enables the `kiwi-vpn` service.", @@ -27,12 +29,12 @@ app = FastAPI( "name": "MIT License", "url": "https://opensource.org/licenses/mit-license.php", }, - openapi_url=Settings._.openapi_url, - docs_url=Settings._.docs_url if not Settings._.production_mode else None, - redoc_url=Settings._.redoc_url if not Settings._.production_mode else None, + openapi_url=settings.openapi_url, + docs_url=settings.docs_url if not settings.production_mode else None, + redoc_url=settings.redoc_url if not settings.production_mode else None, ) -app.include_router(main_router, prefix=f"/{Settings._.api_v1_prefix}") +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 a0e21a9..9b6ebbd 100644 --- a/api/kiwi_vpn_api/routers/__init__.py +++ b/api/kiwi_vpn_api/routers/__init__.py @@ -6,11 +6,12 @@ This file: Main API router definition. from fastapi import APIRouter +from ..config import Settings from . import admin, device, user main_router = APIRouter() -main_router.include_router(admin.router) +main_router.include_router(admin.router, prefix=f"/{Settings._.api_v1_prefix}") main_router.include_router(device.router) main_router.include_router(user.router)