Skip to content

Commit

Permalink
change .env logic and fix remaining funds
Browse files Browse the repository at this point in the history
  • Loading branch information
HamdiBenK committed May 25, 2023
2 parents 5d5090a + 2a86742 commit 62692ee
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 42 deletions.
47 changes: 5 additions & 42 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ require('dotenv').config({
let logger = require('morgan')
let cookieParser = require('cookie-parser')
let path = require('path')
const {swaggerUi, swaggerSpec, cssOptions} = require('./conf/swaggerSetup');
// set up rate limiter: maximum of five requests per minute
var RateLimit = require('express-rate-limit')
const package = require('./package.json')
Expand Down Expand Up @@ -113,6 +114,7 @@ app.use('/auth', loginroutes)
app.use('/wallet', walletroutes)
app.use('/profile', profileroutes)
app.use('/campaign', campaignroutes)
app.use('/docs', swaggerUi.serve, swaggerUi.setup(swaggerSpec, cssOptions));
let host
if (process.env.NODE_ENV == 'testnet') {
host = process.env.BASEURL
Expand All @@ -122,49 +124,10 @@ if (process.env.NODE_ENV == 'testnet') {
host = process.env.BASEURL_MAINNET
}

const swaggerJSDoc = require('swagger-jsdoc')
const swaggerUi = require('swagger-ui-express')
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: [],
},
],
}
var 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)

// if (process.env.NODE_ENV !== 'mainnet') {
// app.use('/docs', swaggerUi.serve, swaggerUi.setup(swaggerSpec, cssOptions))
// }
app.use('/docs', swaggerUi.serve, swaggerUi.setup(swaggerSpec, cssOptions))




// catch 204 and forward to error handler
app.use(function (req, res, next) {
Expand Down
54 changes: 54 additions & 0 deletions conf/swaggerSetup.js
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};

0 comments on commit 62692ee

Please sign in to comment.