This commit is contained in:
Azeez Muibi
2025-04-17 17:50:16 +01:00
parent c4ac25bbdd
commit 21b6e8c018
2 changed files with 29 additions and 1 deletions
+28
View File
@@ -1,12 +1,40 @@
from flask import Blueprint, request, jsonify, send_from_directory
from flask import Blueprint, request, jsonify from flask import Blueprint, request, jsonify
from app.api.services.loan import LoanService from app.api.services.loan import LoanService
from app.api.services.transaction import TransactionService from app.api.services.transaction import TransactionService
from app.api.services.auth_service import AuthService from app.api.services.auth_service import AuthService
from app.api.services.dashboard_service import DashboardService from app.api.services.dashboard_service import DashboardService
from functools import wraps 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 = 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/<path:filename>")
def serve_paths(filename):
swagger_dir = os.path.join("swagger")
return send_from_directory(swagger_dir, filename)
# JWT Authentication decorator # JWT Authentication decorator
def token_required(f): def token_required(f):
+1 -1
View File
@@ -6,7 +6,7 @@ class Config:
"""Base configuration for Flask app""" """Base configuration for Flask app"""
SWAGGER_URL = os.getenv("SWAGGER_URL", "/documentation") 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 DEBUG = True
VALID_APP_ID = os.getenv("VALID_APP_ID", "app1") VALID_APP_ID = os.getenv("VALID_APP_ID", "app1")