-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
40 lines (32 loc) · 1 KB
/
index.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
/**
* connect-heroku-redis
* Copyright(c) 2010 Michael Hemesath <mike.hemesath@gmail.com>
* MIT Licensed
*/
var parse = require("url").parse;
/**
* Return connect heroku redis store
* @param {int} version
* @return RedisStore
* @api public
*/
module.exports = function(connect) {
var RedisStore = require('connect-redis')(connect);
function ConnectHerokuRedis(options) {
var redisToGo = process.env.REDISTOGO_URL ? parse(process.env.REDISTOGO_URL) : false;
console.log("redisToGoURL", redisToGo);
options = options || {};
if (redisToGo) {
options.host = options.host || redisToGo.host;
options.port = options.port || redisToGo.port;
if (!options.pass && redisToGo.auth) {
options.pass = options.pass || redisToGo.auth.split(":")[1];
}
}
console.log("RedisStore options", options);
RedisStore.call(this, options);
}
// Inherit from Connect Redis
ConnectHerokuRedis.prototype = new RedisStore;
return ConnectHerokuRedis;
}