Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixing app.js to allow for heroku. Also adding config.json for heroku…

… test (will remove after)
  • Loading branch information...
commit 321358c89d31f1ebf492867f30eff038a8099295 1 parent be8b9e6
@synedra synedra authored
Showing with 25 additions and 14 deletions.
  1. +13 −14 app.js
  2. +12 −0 config.json
View
27 app.js
@@ -49,18 +49,16 @@ try {
// Redis connection
//
var defaultDB = '0';
-var db = redis.createClient(config.redis.port, config.redis.host);
-db.auth(config.redis.password);
-
-// Select our DB
-db.on("connect", function() {

Why was this block removed? I'm learning though this project and additional clarity would be appreciated. I see it works with or without it. In which case, why did it exist in the first place?

@synedra
synedra added a note

I think it was older code from a previous version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
- db.select(defaultDB);
- db.get("livedocs", function(err, reply) {
- if (config.debug) {
- console.log('Selected db \''+ defaultDB + '\' named \'' + reply + '\'');
- }
- });
-});
+var db;
+
+if (process.env.REDISTOGO_URL) {
+ var rtg = require("url").parse(process.env.REDISTOGO_URL);
+ db = require("redis").createClient(rtg.port, rtg.hostname);
+ db.auth(rtg.auth.split(":")[1]);
+} else {
+ db = redis.createClient(config.redis.port, config.redis.host);
+ db.auth(config.redis.password);
+}
db.on("error", function(err) {
if (config.debug) {
@@ -651,6 +649,7 @@ app.get('/:api([^\.]+)', function(req, res) {
// Only listen on $ node app.js
if (!module.parent) {
- app.listen(config.port, config.address);
+ var port = process.env.PORT || config.port;
+ app.listen(port);
console.log("Express server listening on port %d", app.address().port);
-}
+}
View
12 config.json
@@ -0,0 +1,12 @@
+{
+ "title" : "I/O Docs - http://github.com/mashery/iodocs",
+ "port" : 3000,
+ "debug" : true,
+ "sessionSecret" : "12345",
+ "redis" : {
+ "host" : "localhost",
+ "port" : 6379,
+ "password" : "",
+ "database" : "0"
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.