2025-06-09 11:13:05 +00:00
|
|
|
from flask import Flask
|
|
|
|
from flask_restx import Api
|
|
|
|
from .config import Config
|
|
|
|
from .extensions import init_mongo, init_jwt
|
|
|
|
from .errors.handlers import register_error_handlers
|
|
|
|
from .routes.usage_routes import usage_ns
|
|
|
|
from .routes.auth_routes import auth_ns
|
2025-06-12 20:58:22 +00:00
|
|
|
from .routes.billing_routes import billing_ns
|
2025-06-09 11:13:05 +00:00
|
|
|
from flask_cors import CORS
|
|
|
|
|
|
|
|
def create_app():
|
|
|
|
app = Flask(__name__)
|
|
|
|
app.config.from_object(Config)
|
|
|
|
|
|
|
|
CORS(app, origins=app.config["FRONTEND_URL"], supports_credentials=True)
|
|
|
|
|
|
|
|
init_mongo(app)
|
|
|
|
init_jwt(app)
|
|
|
|
|
|
|
|
api = Api(
|
|
|
|
app,
|
|
|
|
title='Trascription usage API',
|
|
|
|
version='1.0',
|
|
|
|
description='API documentation',
|
|
|
|
doc='/docs',
|
|
|
|
prefix='/api/v1',
|
|
|
|
authorizations={
|
|
|
|
'Bearer Auth': {
|
|
|
|
'type': 'apiKey',
|
|
|
|
'in': 'header',
|
|
|
|
'name': 'Authorization',
|
|
|
|
'description': "Enter your JWT token as: **Bearer <token>**"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
api.add_namespace(usage_ns, path='/usage')
|
|
|
|
api.add_namespace(auth_ns, path='/auth')
|
2025-06-12 20:58:22 +00:00
|
|
|
api.add_namespace(billing_ns, path='/billing')
|
2025-06-09 11:13:05 +00:00
|
|
|
|
|
|
|
register_error_handlers(app)
|
|
|
|
|
|
|
|
return app
|