super-config

0.0.8 • Public • Published

Simple Node Config

Build Status Coverage Status

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

module.exports = {
    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.get('database.host', '');
var port = config.get('database.port', '');
var dbName = config.get('database.dbname', '');

It's that simple.

Setting Information

Need to set some information in the config object? Not a problem:

config.set('database.host', 'mydbserver');

Simple Config, it's THAT simple.

Readme

Keywords

none

Package Sidebar

Install

npm i super-config

Weekly Downloads

2,557

Version

0.0.8

License

MIT

Last publish

Collaborators

  • allysonsuandi
  • psmith22
  • saharzr
  • chrisguitarguy
  • chrisalvares
  • pmgbot
  • emilysnothere
  • eawooten
  • ericelsken
  • andrethio
  • phildier
  • becconk
  • skyemck
  • siephen
  • ian-evidente
  • averycolburn_pmg
  • andrewgazda
  • goodmain
  • talinhall
  • niclee521
  • abdullah.alhamoud
  • shlokkhetan
  • harshithamandru
  • diego.pozo
  • jgmpmg
  • keerthi_kamarthi
  • yashodhara
  • aliciazavala
  • adamdutton08
  • jrughani
  • jwzhang
  • tani-shah
  • satishns
  • bbarnold
  • jay-anderson
  • melvyn1497
  • suneth.tissera
  • ern-z
  • omarassaf106
  • jena
  • theantpile
  • scotthenley
  • jimfurnierpmg
  • adityachaudhari1412
  • evelynli
  • katthartic
  • kendrick-mcadams
  • noahwebber
  • joshua.dienye
  • abdallahhwishel
  • aayush1999
  • datamadeeezy
  • edwardpmg
  • varun27896
  • lawirmuhammed
  • rafi-pmg
  • williamng822
  • lk45
  • sairashe001
  • bliuh
  • jordanrussell
  • bquach1
  • adiv24
  • artem.polupan.pmg
  • parasavellipmg
  • reedcowan
  • ericelskenpmg
  • jond85
  • johnforstmeierpmg
  • asreedy82
  • pmg-sevenonethree
  • phariharan818
  • cadebauer
  • johnathan.rodriguez
  • andypmg
  • huanyangpmg
  • maqsood-pmg