Skip to content

Commit

Permalink
Updated to v1.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
its0x4d committed Dec 13, 2023
1 parent 221c4bc commit 1e910b6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions fastapi_jet/commands/applist.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def app_list():

main_core = __import__("base.main", fromlist=["main"])
apps_table = []
for route in main_core.ROUTERS:
for route in main_core.INSTALLED_APPS:
apps_table += [
[route['name'], f"apps/{route['name']}/router.py"],
]
Expand All @@ -38,7 +38,7 @@ def routes_list(

main_core = __import__("base.main", fromlist=["main"])
main_routes = []
for _route in main_core.ROUTERS:
for _route in main_core.INSTALLED_APPS:
if app_name != "all" and _route['name'] != app_name:
continue
imported_app = __import__(f"apps.{_route['name']}.routers", fromlist=["router"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# The first element is the app name and the second element is the app's prefix.
# To enable app routers, add them here along with their prefixes.
# e.g. AppRoute(name="auth_app", prefix="/v1/auth", tags=ADD_TAGS_HERE)
ROUTERS = [
INSTALLED_APPS = [

]

Expand All @@ -29,4 +29,4 @@
# Include the middlewares in the FastAPI application.
include_middlewares(fast_api_app=app, middlewares=MIDDLEWARES)
# Include the routers in the FastAPI application.
include_routers(fast_api_app=app, routers=ROUTERS)
include_routers(fast_api_app=app, installed_apps=INSTALLED_APPS)
10 changes: 5 additions & 5 deletions fastapi_jet/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@
from fastapi_jet.context import AppRoute


def include_routers(fast_api_app: FastAPI, routers: List[AppRoute], apps_path: str = "apps") -> None:
def include_routers(fast_api_app: FastAPI, installed_apps: List[AppRoute], apps_path: str = "apps") -> None:
"""
This function is used to include routers from the ROUTERS list in the main file.
:param fast_api_app: The FastAPI application where the routers will be included.
:type fast_api_app: FastAPI
:param routers: A list of AppRoute objects, where each object contains the name of an app
:type routers: list
:param installed_apps: A list of AppRoute objects, where each object contains the name of an app
:type installed_apps: list
:param apps_path: The path to the apps' folder. Defaults to "apps".
:type apps_path: str, optional
:return: None
"""
for route in routers:
for route in installed_apps:
route_module = f"{route['name']}.routers" if apps_path == '.' else f"{apps_path}.{route['name']}.routers"
_route = __import__(route_module, fromlist=["router"]).__dict__["router"]
_route = __import__(route_module, fromlist=["router"])
route = route.copy()
route.pop('name')
fast_api_app.include_router(_route.router, **route)
Expand Down

0 comments on commit 1e910b6

Please sign in to comment.