I've written a module for gathering configuration parameters from common 
environment variables:

https://github.com/stuartpb/envigor

Here's the README section on usage:

Say you're making an Express app with MongoDB, that you're writing for a 
service like Heroku, with addons like MongoLab to provide your more general 
services like MongoDB. By using envigor, you can set your app up to find a 
configured MongoDB service with complete service agnosticism:

npm install --save envigor mongodb
heroku addons:add mongolab

server.js:

var http = require('http')var cfg = require('envigor')();
var app = require('./app.js')(cfg);http.createServer(app).listen(cfg.port || 
5000, function() {
  console.log("Listening on " + port);});

app.js:

var express = require('express');module.exports = function(cfg){
  var app = express();

  mongodb.MongoClient.connect(cfg.mongodb.url,function(err,db){
    if(err) throw err; else app.set('db',db)
  }

  // ...your routes here...

  return app;}

Also, I haven't tested it yet, but you should be able to set up an outgoing 
email service like Mandrill or Sendgrid with 
nodemailer.createTransport('SMTP',envigor().smtp).

These are just the couple of areas where I've dealt with configuration 
quirks before - if anybody has any services or API configurations they'd 
like to add (like Twitter or Redis, which are only missing for my lack of 
familiarity), please, send me a pull request.

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to