node.js: standard way to store app's configuration?

Problem

Is there standard ways of storing node.js app's configuration for different environments?

What I did to accomplish this:

created: node_app_folder/conf/general.js node_app_folder/conf/development.js node_app_folder/conf/production.js

general.js:

module.exports = {
    setting: "SOME GENERAL SETTING"
   ,setting2: ...
    ...
   // global conf has export method extend that just copies/replaces properties from supplied object
   extend: {...}

}

development.js and production.js contain setting specific for the environment.

in app.js:

global.conf = require('./conf/general');

// As I use express.js
app.configure('development', function(){       
   global.conf.extend(require('./conf/development'));
   ....
}
app.configure('production', function(){       
   global.conf.extend(require('./conf/producton'));
   ....
}

So then in my app's modules I can access app, configuration via global.conf object.

But I wonder if there are standard ways of doing the described task?

Thanks.

Problem courtesy of: WHITECOLOR

Solution

If you just want to get the values from JSON files then using Konphyg is perfect, here's a nice tutorial about it: http://nodetuts.com/tutorials/31-konphyg-cascading-configuration-files.html

There is no standard way of setting the configuration folder though, each does it in his own way.

Solution courtesy of: alessioalex

Discussion

There is currently no discussion for this recipe.

This recipe can be found in it's original form on Stack Over Flow.