-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
46 lines (37 loc) · 1.21 KB
/
Copy pathindex.js
File metadata and controls
46 lines (37 loc) · 1.21 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
43
44
45
46
'use strict';
var fs = require('fs'),
http = require('http'),
path = require('path');
var express = require("express");
var app = express();
var bodyParser = require('body-parser');
app.use(bodyParser.json({
strict: false,
limit: '50mb'
}));
var oasTools = require('oas-tools');
var jsyaml = require('js-yaml');
var serverPort = process.env.PORT || 8080;
var spec = fs.readFileSync(path.join(__dirname, '/api/oas-doc.yaml'), 'utf8');
var oasDoc = jsyaml.safeLoad(spec);
var options_object = {
controllers: path.join(__dirname, './controllers'),
loglevel: 'error',
strict: false,
router: true,
validator: true
};
oasTools.configure(options_object);
oasTools.initialize(oasDoc, app, function () {
http.createServer(app).listen(serverPort, function () {
console.log("App running at http://localhost:" + serverPort);
console.log("________________________________________________________________");
if (options_object.docs !== false) {
console.log('API docs (Swagger UI) available on http://localhost:' + serverPort + '/docs');
console.log("________________________________________________________________");
}
});
});
app.get('/', function (req, res) {
res.redirect('/docs');
});