var redis = require('redis');

function getConnection() {
  var db = redis.createClient();
  db.select(6, function (err) { if (err) throw err; });
  return db;
}

exports.redis = redis;
exports.getConnection = getConnection;

@@ -37,114 +37,582 @@
 ion 
-getConnection() %7B%0A  var db = redis.createClient();%0A  db.select(6, function (err) %7B if (err) throw err; %7D);
+throwError(err) %7B%0A  if (err) %7B%0A    throw err;%0A  %7D%0A%7D%0A%0Afunction logError(err) %7B%0A  console.log(err);%0A%7D%0A%0Afunction getConnection() %7B%0A  var port = process.env.REDIS_PORT %7C%7C 6379,%0A      host = process.env.REDIS_HOST %7C%7C '127.0.0.1',%0A      password = process.env.REDIS_PASS,%0A      dbNumber = process.env.REDIS_DB;%0A  var db = redis.createClient(port, host);%0A  db.on('error', logError);%0A%0A  var callback = throwError;%0A  if (dbNumber) %7B%0A    callback = function() %7B db.select(dbNumber, throwError); %7D;%0A  %7D%0A%0A  if (password) %7B%0A    db.auth(password, callback);%0A  %7D else %7B%0A    callback();%0A  %7D
 %0A  r

Make redis helper production-ready