This repository has been archived by the owner on Nov 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
74 lines (59 loc) · 2.18 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
'use strict';
var express = require('express');
var routes = require('./routes');
var http = require('http');
var path = require('path');
var socketio = require('socket.io');
var app = express();
var redis = require('redis');
var client = redis.createClient();
var port = process.env.PORT;
app.set('port', port || 3000);
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.use(express.favicon());
app.use(express.static(path.join(__dirname, 'public')));
app.use(express.logger('short'));
app.use(express.bodyParser());
app.use(app.router);
if (app.env === 'development') {
app.use(express.errorHandler());
}
app.get('/', routes.index);
app.post('/createUser', routes.createUser);
app.post('/checkUser', routes.checkUser);
app.post('/deleteFile', routes.deleteFile);
var server = http.createServer(app).listen(app.get('port'), function() {
console.log('Paranot.es server listening on port ' + app.get('port'));
});
var io = socketio.listen(server);
routes.init(io);
var redisPort = 6379;
var redisHost = 'localhost';
var RedisStore = require('socket.io-redis');
var pub = redis.createClient(redisPort, redisHost);
var sub = redis.createClient(redisPort, redisHost);
var store = redis.createClient(redisPort, redisHost);
//global redis client
client = redis.createClient(redisPort, redisHost);
//no auth for now;
/*pub.auth(password, function (err) { if (err) throw err; });
sub.auth(password, function (err) { if (err) throw err; });
client.auth(password, function (err) { if (err) throw err; });*/
io.set('store', new RedisStore({
redisPub: pub,
redisSub: sub,
redisClient: store
}));
/**io.configure(function() {
io.enable('browser client minification'); // send minified client
io.enable('browser client etag'); // apply etag caching logic based on version number
io.enable('browser client gzip'); // gzip the file
io.set('log level', 1); // reduce logging
io.set('transports', [ // enable all transports (optional if you want flashsocket)
'websocket', 'flashsocket', 'htmlfile', 'xhr-polling', 'jsonp-polling']);
var RedisStore = require('socket.io/lib/stores/redis');
});*/
// enable socket io
var realtime = require('./realtime/rt.js');
realtime(io, client);