-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
27 lines (21 loc) · 803 Bytes
/
app.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
'use strict';
var SwaggerExpress = require('swagger-express-mw');
var app = require('express')();
var SwaggerUi = require('swagger-tools/middleware/swagger-ui');
module.exports = app; // for testing
var config = {
appRoot: __dirname // required config
};
SwaggerExpress.create(config, function(err, swaggerExpress) {
if (err) { throw err; }
// Add swagger-ui (This must be before swaggerExpress.register)
app.use(SwaggerUi(swaggerExpress.runner.swagger));
// install middleware
swaggerExpress.register(app);
// app.use('/api-docs', express.static(__dirname + '/public/docs'));
var port = process.env.PORT || 10010;
app.listen(port);
if (swaggerExpress.runner.swagger.paths['/hello']) {
console.log('try this:\ncurl http://127.0.0.1:' + port + '/hello?name=Scott');
}
});