/
swaggerSetup.js
54 lines (49 loc) · 1.37 KB
/
swaggerSetup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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};