forked from mixit-craftsmanship/mixit-craftsmanship
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
47 lines (37 loc) · 1.39 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
var express = require('express');
var http = require('http');
var methodOverride = require('method-override');
var bodyParser = require('body-parser');
var staticFavicon = require('static-favicon');
var morgan = require('morgan');
var socketIO = require('socket.io');
var compression = require('compression');
var staticFilesRoute = require('./routes/staticFiles');
var talksRoute = require('./routes/talks');
var talkVotesRoute = require('./routes/talkVotes');
var applicationVersionRoute = require('./routes/applicationVersion');
var votesStore = require('./libs/votesStore');
var configuration = require('./configuration');
var app = express();
// all environments
app.set('port', process.env.PORT || 3000);
app.use(compression());
app.use(staticFavicon());
app.use(morgan('dev'));
app.use(bodyParser());
app.use(methodOverride());
var env = process.env.NODE_ENV || 'development';
talksRoute.register(app);
applicationVersionRoute.register(app);
staticFilesRoute.register(app, 'development' == env);
var server = http.createServer(app);
socketIO = socketIO.listen(server);
server.listen(app.get('port'), function(){
console.log('Express server listening on port ' + app.get('port'));
});
talkVotesRoute.register(socketIO.sockets);
if(process.env.MONGO_MIXIT){
console.log('initialize mongodb');
configuration.mongoConfiguration.uri = process.env.MONGO_MIXIT;
votesStore.configuration(1000);
}