-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathworker.js
62 lines (52 loc) · 1.66 KB
/
worker.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
61
62
/**
* Module dependencies.
*/
var express = require('express'),
RedisStore = require('connect-redis')(express),
redisClient = require('redis').createClient(),
routes = require('./routes'),
http = require('http'),
path = require('path'),
sessionGenerator = require('./src/sessionGenerator'),
sessionStore = new RedisStore({
host: 'localhost',
port: 6379,
db: 2
}),
WhosOnline = require('./src/WhosOnline'),
app = express(),
server = http.createServer(app),
errorHandler = require('./src/errorHandler');
app.engine('html', require('hogan-express'));
app.enable('view cache');
app.configure(function(){
app.set('port', process.env.PORT || 3000);
app.set('view engine', 'html');
app.set('partials', {head: 'head', footer: 'footer', leftcolumn: 'leftcolumn'});
app.use(express.favicon(__dirname + '/public/favicon.ico'));
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.cookieParser('0rly?YA,rly!'));
app.use(express.static(path.join(__dirname, 'public')));
app.use(express.session({
store: sessionStore,
secret: '0mg!Wtf?bbQ!',
reapInterval: 60*60*1000
}));
app.use(function(req, res, next){
if(req.session.user && req.session.user.username){
WhosOnline.setOnline(req.session.user.username);
}
next();
});
app.use(routes());
app.use(errorHandler);
WhosOnline.setStore(redisClient);
});
app.configure('development', function(){
app.use(express.errorHandler());
});
server.listen(app.get('port'), function(){
console.log("Express server listening on port " + app.get('port'));
});