-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.js
30 lines (23 loc) · 804 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
const
path = require('path'),
express = require('express'),
bodyParser = require('body-parser');
const port = process.env.PORT || 3000;
let app = express();
app.use(bodyParser.urlencoded({
extended: true,
}));
app.use(bodyParser.json());
app.use(function (req, res, next) {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,origin,content-type,accept');
res.setHeader('Access-Control-Allow-Credentials', true);
next();
});
const router = require('./routes')(app);
router.get('*', (req, res) => {
res.sendFile(path.join(__dirname + '/README.html'));
});
app.listen(port);
console.log(`Magic happens on port: ${port}`);