-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
51 lines (41 loc) · 1.06 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// modules
var express = require('express')
, http = require('http')
, morgan = require('morgan')
, compression = require('compression');
// configuration files
var configServer = require('./server/config/server');
var bodyParser = require('body-parser')
// app parameters
var app = express();
app.use(compression());
app.set('port', configServer.httpPort);
app.use(express.static(configServer.staticFolder));
app.use(morgan('dev'));
app.use(bodyParser.urlencoded({
extended: true,
limit: '50mb'
}));
app.use(bodyParser.json());
// serve index
require('./server/routes').serveIndex(app, configServer.staticFolder);
if(global.gc) {
var gcInterval;
function init()
{
gcInterval = setInterval(function() { gcDo(); }, 60000);
}
function gcDo()
{
global.gc();
clearInterval(gcInterval);
init();
}
init();
}
// HTTP server
var server = http.createServer(app);
server.listen(app.get('port'), function () {
console.log('HTTP server listening on port ' + app.get('port'));
});
module.exports.app = app;