-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
41 lines (35 loc) · 852 Bytes
/
index.js
File metadata and controls
41 lines (35 loc) · 852 Bytes
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
#!/usr/bin/env node
var express = require('express');
var http = require('http');
var router = require('./lib/router.js');
var log = require('./lib/log');
// Parameters
PORT=8080
/*
* Express configuration
*/
var app = express();
// Allow Request from anywhere
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();
});
app.use('/api', router);
app.use('/', express.static(__dirname + '/public'));
/*
* HTTP server
*/
var server = http.createServer(app);
server.listen(PORT, function() {
log.debug('HTTP server is listening on ' + PORT);
});
/*
* Process handling
*/
process.on('SIGINT', function () {
log.warn("Exit called");
setTimeout(function () {
process.exit(0);
}, 200);
});