Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Modify REDISTOGO_URL parameters #175

Merged
merged 4 commits into from

2 participants

Scott Switzer Neil Mansilla
Scott Switzer

I made three related changes:

  1. Allowed the ability to use REDIS_URL as well as REDISTOGO_URL environment variable to set redis params.
  2. Added better parsing functionality for password in the Redis URL
  3. Switched from Optimist to Yargs, since Optimist is deprecated and suggests going to Yargs.
Neil Mansilla mansilladev merged commit 5c08aec into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 7 additions and 7 deletions.
  1. +6 −6 app.js
  2. +1 −1  package.json
12 app.js
View
@@ -40,16 +40,16 @@ var express = require('express'),
RedisStore = require('connect-redis')(express);
// Parse arguments
-var optimist = require('optimist')
+var yargs = require('yargs')
.usage('Usage: $0 --config-file [file]')
.alias('c', 'config-file')
.alias('h', 'help')
.describe('c', 'Specify the config file location')
.default('c', './config.json');
-var argv = optimist.argv;
+var argv = yargs.argv;
if (argv.help) {
- optimist.showHelp();
+ yargs.showHelp();
process.exit(0);
}
@@ -69,11 +69,11 @@ var defaultDB = '0';
if(config.redis) {
config.redis.database = config.redis.database || defaultDB;
-if (process.env.REDISTOGO_URL) {
- var rtg = require("url").parse(process.env.REDISTOGO_URL);
+if (process.env.REDISTOGO_URL || process.env.REDIS_URL) {
+ var rtg = require("url").parse(process.env.REDISTOGO_URL || process.env.REDIS_URL);
config.redis.host = rtg.hostname;
config.redis.port = rtg.port;
- config.redis.password = rtg.auth.split(":")[1];
+ config.redis.password = rtg.auth && rtg.auth.split(":")[1] ? rtg.auth.split(":")[1] : '';
}
var db = redis.createClient(config.redis.port, config.redis.host);
2  package.json
View
@@ -31,7 +31,7 @@
"redis": "0.8.3",
"querystring": "0.1.0",
"supervisor": ">= 0.5.x",
- "optimist": ">= 0.6.0"
+ "yargs": ">= 1.2.1"
},
"devDependencies": {},
"main": "index",
Something went wrong with that request. Please try again.