diff --git a/app/api/routes/routes.py b/app/api/routes/routes.py index 245ce07..8f79b44 100644 --- a/app/api/routes/routes.py +++ b/app/api/routes/routes.py @@ -1,12 +1,40 @@ +from flask import Blueprint, request, jsonify, send_from_directory from flask import Blueprint, request, jsonify from app.api.services.loan import LoanService from app.api.services.transaction import TransactionService from app.api.services.auth_service import AuthService from app.api.services.dashboard_service import DashboardService from functools import wraps +from app.utils.logger import logger +from app.api.middlewares import enforce_json, require_auth +import os +from flask_jwt_extended import ( + JWTManager, + jwt_required, + create_access_token, + get_jwt_identity, + create_refresh_token, +) api = Blueprint('api', __name__) +@api.before_request +def cors_middleware(): + """Middleware applied globally to all API routes in this blueprint""" + return enforce_json() + + +# Swagger JSON file +@api.route("/swagger.json", methods=["GET"]) +def swagger_json(): + swagger_dir = os.path.join("swagger") + return send_from_directory(swagger_dir, "digifi_swagger.json") + + +@api.route("/swagger/") +def serve_paths(filename): + swagger_dir = os.path.join("swagger") + return send_from_directory(swagger_dir, filename) # JWT Authentication decorator def token_required(f): diff --git a/app/config.py b/app/config.py index d1f3065..93e37d8 100644 --- a/app/config.py +++ b/app/config.py @@ -6,7 +6,7 @@ class Config: """Base configuration for Flask app""" SWAGGER_URL = os.getenv("SWAGGER_URL", "/documentation") - API_URL = os.getenv("API_URL", "/swagger.json") + API_URL = os.getenv("API_URL", "/digifi_swagger.json") DEBUG = True VALID_APP_ID = os.getenv("VALID_APP_ID", "app1")