-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
29 lines (23 loc) · 898 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
var app = (require('express'))(),
apiRouter = require('./app/apiRouter');
(require('node-env-file'))(__dirname + '/.env');
app.use(function (req, res, next) {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods',
'GET, POST, PUT, PATCH, DELETE, OPTIONS');
res.setHeader('Access-Control-Allow-Headers',
'X-Requested-With, content-type, authorization,' +
' accept, origin');
res.setHeader('Access-Control-Allow-Credentials', 'true');
if (req.method === "OPTIONS") {
return res.status(200).json({
status: 200,
message: "OPTIONS request"
});
}
next();
});
app.use('/api/' + process.env.VERSION, apiRouter);
app.listen(process.env.PORT, function () {
console.log('Started listening at port ' + process.env.PORT);
});