-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## PR Description Hey team, This pull request aims to improve the code structure and organization of the app.js file in our GitHub repository. The main objective is to enhance maintainability and readability by moving the Swagger configuration code to a separate file called setupSwagger.js. By doing this, we can achieve better separation of concerns and adhere to the single responsibility principle. ## Changes Made - Created a new file called setupSwagger.js in the appropriate directory. - Transferred the Swagger configuration code from app.js to setupSwagger.js. - Updated the app.js file to import the necessary functions or configurations from setupSwagger.js. - Verified that the application remains functional after the code refactoring. ## Notes for Reviewers Please review the changes made in this pull request carefully, paying particular attention to the new setupSwagger.js file and the modifications in app.js. Any feedback, suggestions, or improvements are welcome Best regards, Louay HICHRI
- Loading branch information
Showing
2 changed files
with
59 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
const swaggerUi = require('swagger-ui-express') | ||
const swaggerJSDoc = require('swagger-jsdoc') | ||
const package = require('./../package.json') | ||
require('dotenv').config() | ||
let host | ||
if (process.env.NODE_ENV == 'testnet') { | ||
host = process.env.BASEURL | ||
} else if (process.env.NODE_ENV == 'local') { | ||
host = process.env.BASEURLLOCAL | ||
} else { | ||
host = process.env.BASEURL_MAINNET | ||
} | ||
const swaggerDefinition = { | ||
openapi: '3.0.0', | ||
info: { | ||
title: 'API for node-satt', | ||
version: package.version, | ||
description: | ||
'Welcome to SaTT Webservice endpoint, this backend provides webservice to SaTT WebWallet and advertising campaign manager', | ||
customCss: '.swagger-ui .topbar { display: none }', | ||
}, | ||
host: host, | ||
components: { | ||
securitySchemes: { | ||
bearerAuth: { | ||
type: 'http', | ||
scheme: 'bearer', | ||
bearerFormat: 'JWT', | ||
}, | ||
}, | ||
}, | ||
security: [ | ||
{ | ||
bearerAuth: [], | ||
}, | ||
], | ||
} | ||
|
||
const cssOptions = { | ||
customCss: ` | ||
.topbar-wrapper img {content:url(/assets/SaTT.png); width:50px; height:auto;}`, | ||
customSiteTitle: 'SaTT', | ||
customfavIcon: '/assets/SaTT-noire.png', | ||
} | ||
|
||
const options = { | ||
swaggerDefinition, | ||
apis: ['./routes/*.js'], | ||
} | ||
const swaggerSpec = swaggerJSDoc(options) | ||
|
||
|
||
|
||
module.exports = {swaggerUi, swaggerSpec, cssOptions}; |