-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
33 lines (24 loc) · 858 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
28
29
30
31
32
33
'use strict';
var SwaggerExpress = require('swagger-express-mw');
var app = require('express')();
module.exports = app; // for testing
// configuration to read from swagger.json??
// var express = require("express");
// app.use(express.json());
// another configuration to read from swagger.json??
// var bodyParser = require('body-parser');
// app.use(bodyParser.urlencoded({extended: false}));
var config = {
appRoot: __dirname // required config
// swaggerFile: 'api/swagger/swagger.json'
};
SwaggerExpress.create(config, function(err, swaggerExpress) {
if (err) { throw err; }
// install middleware
swaggerExpress.register(app);
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');
}
});