Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
applicationServer.listen( port );
console.log( "Listening on port " + port );
/*************************
* Web Socket Communication
*************************/
// Initialize socket.io using redis store
var io = sockets.listen( applicationServer );
io.set( 'log level', 2 );
// Use redis store to support multi-process/server communication
var RedisStore = require('socket.io/lib/stores/redis');
io.set('store', new RedisStore({
redisPub : redis.createClient(),
redisSub : redis.createClient(),
redisClient : redis.createClient()
}));
function updateRoomCount( roomId ) {
return participation.count(roomId, withCount);
function withCount( err, count ) {
if ( err )
return console.log(err);
io.sockets.in(roomId).json.emit('message', {count:count})
}
}
// Use join message to register as a participant
var bodyParser = require('body-parser');
var redisClient = require('redis').createClient();
var path = require('path');
var util = require('../lib/utility.js');
var multer = require('multer');
var sharp = require('sharp');
const configWP = require('../../webpack.config.js');
const webpack = require('webpack');
const webpackDevMiddleware = require('webpack-dev-middleware');
const webpackHotMiddleware = require('webpack-hot-middleware');
var memstorage = multer.memoryStorage();
var upload = multer({
storage: memstorage,
limits: { fileSize: 1 * 1000 * 500 }, // 500kb
});
var passport = require('passport');
var RedisStore = function(options) {
options = defaults(options, {
expiry: 60, // default expiry is one minute
prefix: "rl:",
resetExpiryOnChange: false,
redisURL: undefined,
});
var expiryMs = Math.round(1000 * options.expiry);
// create the client if one isn't provided
options.client = options.client || redis.createClient(options.redisURL);
var setExpire = function(replies, rdskey) {
// if this is new or has no expiry
if (options.resetExpiryOnChange || replies[0] === 1 || replies[1] === -1) {
// then expire it after the timeout
options.client.pexpire(rdskey, expiryMs);
return expiryMs;
} else {
return replies[1];
}
};
var processReplies = function(replies) {
// in ioredis, every reply consists of an array [err, value].
// We don't need the error here, and if we aren't dealing with an array,
// nothing is changed.
engine.load = function (resourceful, data, callback) {
var conn = redis.createClient();
var stuff = [];
data = data.forEach(function (r) {
r = JSON.parse(JSON.stringify(r));
r.id = r._id;
delete r._id;
stuff.push('resourceful:' + engine.options.namespace + ':id:' + r.id);
stuff.push(JSON.stringify(r));
});
conn.flushdb(function() {
conn.mset(stuff, callback);
});
};
var Thoonk = function(host, port) {
EventEmitter.call(this);
this.setMaxListeners(1000);
this.host = host || 'localhost';
this.port = port || 6379;
this.redis = redis.createClient(this.port, this.host);
this.lredis = redis.createClient(this.port, this.host);
this.ready = false;
this.lredis.on('message', function(channel, msg) {
msg = msg.toString();
this.emit(channel, channel, msg);
}.bind(this));
this.lredis.on('subscribe', function(channel) {
this.emit('subscribed.' + channel);
}.bind(this));
this.scripts = {};
this.shas = {};
this.instance = uuid();
function initRedis(cb) {
console.log('initing redis');
redisClient = redis.createClient(userDb.port, userDb.host);
redisClient.on("error", function (err) {
console.log("error event - " + redisClient.host + ":" + redisClient.port + " - " + err);
});
redisClient.auth(userDb.pwd, function() {
console.log('redis auth done');
//redisClient.stream.on('connect', cb);
cb();
});
}
function browseridVerify(obj, cb) {
queue.Subscribe = function(config) {
subscriberClient = subscriberClient || redis.createClient(config.port, config.host, config.options);
subscriberClient.setMaxListeners(0);
var emitter = new EventEmitter();
function onClientMessage(channel, message) {
if (channel !== config.channel) return;
process.nextTick(function() {
var parsedMessage;
try {
parsedMessage = JSON.parse(message);
} catch (e) {
emitter.emit('error', e);
return;
}
emitter.emit('message', parsedMessage);
});
utilities_1.fastCHAIN(Object.keys(_this._pkKey), function (item, i, next) {
_this._dbClients[item] = redis.createClient(_this.connectArgs);
_this._dbClients[item].on("ready", function () {
_this._dbClients[item].select(_this._DBIds[item], next);
});
}).then(function () {
getIndexes();
function setupStatsRedis(){
redisStats = redis.createClient(portalConfig.redis.port, portalConfig.redis.host);
if(portalConfig.redis.password){
redisStats.auth(portalConfig.redis.password);
};
}
let start = function start() {
cache = redis.createClient()
}