-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.js
42 lines (32 loc) · 964 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
34
35
36
37
38
39
40
41
42
'use strict';
//loading information from
if (process.env.NODE_ENV !== 'production') {
require('dotenv').config();
}
var SwaggerExpress = require('swagger-express-mw');
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const path = require('path')
const cors = require('cors');
app.use(express.static(path.join('public')));
app.use(bodyParser.json());
app.use(cors());
const verify = require('./api/controllers/validation.js');
var config = {
appRoot: __dirname // required config
};
//applying middleware to get user package route
app.get('/users/:id/packages', verify.middlewareVerify);
SwaggerExpress.create(config, function(err, swaggerExpress) {
if (err) {
throw err;
}
// install middleware
swaggerExpress.register(app);
var port = process.env.PORT || 10010;
app.listen(port, () => {
console.log('listening on port ' + port);
});
});
module.exports = app; // for testing