-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
34 lines (28 loc) · 864 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
30
31
32
33
34
// General require
const port = 3000
// Express module
const express = require('express')
const bodyParser = require('body-parser')
const app = express()
// Express route
const EnableRoute = require('./src/routes/enable.route')
app.use(function (req, res, next) {
res.header('Access-Control-Allow-Origin', '*')
res.header('Access-Control-Allow-Credentials', 'true')
res.header('Access-Control-Allow-Methods', 'GET,HEAD,PUT,PATCH,POST,DELETE')
res.header('Access-Control-Expose-Headers', 'Content-Length')
res.header(
'Access-Control-Allow-Headers',
'Accept, Authorization, Content-Type, X-Requested-With, Range'
)
if (req.method === 'OPTIONS') {
return res.sendStatus(200)
} else {
return next()
}
})
app.use(bodyParser.json())
EnableRoute.routesConfig(app)
app.listen(port, function () {
console.log('Port: %s', port)
})