forked from nomiddlename/flair-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
37 lines (31 loc) · 778 Bytes
/
index.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
var express = require('express')
, defaults = {
supportHeaderParams: false,
apiKey: 'special-key'
};
module.exports = function(swaggerUrl, options) {
var app = express()
, opts = merge(defaults, options);
function render(req, res) {
res.render('index.ejs', { discoveryUrl: swaggerUrl, options: opts });
}
app.set('views', __dirname);
app.engine('ejs', require('ejs').__express);
app.get('/index.html', render);
app.use(express.static(__dirname + '/node_modules/swagger-ui/dist'));
app.get('/', render);
return app;
};
function copy(dest, src) {
if (src) {
Object.keys(src).forEach(function(property) {
dest[property] = src[property];
});
}
}
function merge(a, b) {
var c = {};
copy(c, a);
copy(c, b);
return c;
}