forked from 55sketch/gsx2json
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
32 lines (24 loc) · 744 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
var api = require('./api');
var express = require('express');
var path = require('path');
var bodyParser = require('body-parser');
var app = express();
var port = process.env.PORT || 5000;
app.use(function(req, res, next) {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
next();
});
// body parser middleware
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
// get api
app.get('/api', api);
// error handler
app.use(function(err, req, res, next) {
console.error(err.stack);
res.status(400).send(err.message);
});
app.listen(port, function() {
console.log('GSX2JSON listening on port ' + port);
});