-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
60 lines (49 loc) · 1.76 KB
/
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
'use strict';
var express = require('express');
var bodyParser = require('body-parser');
var kraken = require('kraken-js');
var path = require('path');
var fs = require('fs');
var options, app;
options = {
onconfig: function (config, next) {
// set a global accessable module
require('./lib/config').set(config);
// allow command line switch from serving /dist to /app
if( config.get('dev') ) {
var middleware = config.get('middleware').static;
middleware.module.arguments[0] = middleware.module.arguments[0].replace(/dist$/,'app');
console.log('Servering ./app');
//var polyNext = require('/Users/jrmerz/dev/personal/poly-next-core');
var polyNext = require('poly-next-core');
app.use(polyNext.middleware({
root : path.join(__dirname, 'app'),
pushMessages : false,
modules : [{
urlpath : 'elements',
name : 'index'
}]
}));
}
require('./lib/pg').connect(function(){
var model = require('./models/weather')();
next(null, config);
});
}
};
app = express();
app.use(kraken(options));
app.use(bodyParser.json({limit: '500mb'}));
app.use(bodyParser.urlencoded({limit: '500mb', extended: true}));
app.on('start', function () {
console.log('Application ready to serve requests.');
console.log('Environment: %s', app.kraken.get('env:env'));
});
var http = require('http');
var server = http.createServer(app);
server.listen(process.env.PORT || 8000);
server.timeout = 5 * 60 * 1000;
require('./lib/socket').init(server);
server.on('listening', function () {
console.log('Server listening on http://localhost:%d', this.address().port);
});