Simple Node Config
This light-weight NodeJS package allows you to load your config files, as well as easily edit them with getters and setters. The files have to be in JSON format.
Examples
Loading Config Files
Store the super-config
class in a variable and load as many configuration files as you have.
var config = require('super-config');
config.loadConfig([
__dirname + '/app/config/config',
__dirname + '/app/config/local'
]);
It's that simple.
Example config file
moduleexports = database: host:'127.0.0.1' port:'27017' dbname:'example_DB' someOtherSetting: 1234 name: 'myname'
Getting Information
Let's pretend our config file contains this section of code:
database: host:'127.0.0.1' port:'27017' dbname:'example_DB'
It would pretty nice if we could easily retrieve that information right? Here's how-to:
var host = config;var port = config;var dbName = config;
It's that simple.
Setting Information
Need to set some information in the config object? Not a problem:
config;
Simple Config, it's THAT simple.