Skip to content

Commit

Permalink
♻️ refactor: refactor restful resources
Browse files Browse the repository at this point in the history
  • Loading branch information
ayoub3bidi committed Oct 5, 2023
1 parent cdc9fa4 commit c6ddfbd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/main.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
from routes import user, health
import middleware.auth_guard as auth_guard
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
import os
import redis
from database.postgres_db import dbEngine, Base
import database.redis_db as redis
from restful_ressources import import_resources

app_version = os.environ['APP_VERSION']
app_title = os.environ['APP_TITLE']
app_description = os.environ['APP_DESCRIPTION']
v = os.environ['API_VERSION']

Base.metadata.create_all(bind=dbEngine)
redis.init()
Expand All @@ -31,6 +29,4 @@
allow_headers=["*"],
)

app.include_router(health.router, tags=['Information'], prefix=f'/{v}')
app.include_router(auth_guard.router, tags=['Access Token'], prefix=f'/{v}')
app.include_router(user.router, tags=['User'], prefix=f'/{v}/user')
import_resources(app)
11 changes: 11 additions & 0 deletions src/restful_ressources.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

import os
from routes import user, health
import middleware.auth_guard as auth_guard

v = os.environ['API_VERSION']

def import_resources(app):
app.include_router(health.router, tags=['Information'], prefix=f'/{v}')
app.include_router(auth_guard.router, tags=['Access Token'], prefix=f'/{v}')
app.include_router(user.router, tags=['User'], prefix=f'/{v}/user')

0 comments on commit c6ddfbd

Please sign in to comment.