-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathapi-reference.js
More file actions
executable file
·42 lines (39 loc) · 1.43 KB
/
api-reference.js
File metadata and controls
executable file
·42 lines (39 loc) · 1.43 KB
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
const swaggerUi = require('swagger-ui-express')
module.exports = function (app) {
const options = {
swaggerUrl: 'https://api.swaggerhub.com/apis/nutes.ocariot/OCARIoT/v1/swagger.json',
customCss: `.swagger-ui .topbar {
background-color: #0097a7;
padding: 14px 0;
}
.swagger-ui .topbar .topbar-wrapper a span {
display: none;
}
.swagger-ui .topbar .topbar-wrapper a {
display: none;
}
.swagger-ui .topbar .topbar-wrapper:before {
content: url(/images/logo-32x32.png);
margin-left: -5px;
}
.swagger-ui .topbar .topbar-wrapper:after {
content: 'OCARIoT';
margin: 0;
padding: 0 10px;
font-size: 1.7em;
font-weight: 700;
color: #fff;
}`,
customfavIcon: '/images/favicon-16x16.png',
customSiteTitle: 'API Reference | OCARIoT'
}
app.get('/', (req, res, next) => {
if (req.hostname === (process.env.API_GATEWAY_HOSTNAME || '')) {
return res.redirect('/v1/reference')
}
next()
})
app.use('/v1/reference', swaggerUi.serve, (req, res) => {
swaggerUi.setup(null, options)(req, res)
})
}