Nurturing Palpable Magnificence
    Wondering what’s next for npm?Check out our public roadmap! »

    @samwen/config-util

    1.0.5 • Public • Published

    config-util

    An configuration util to support multiple environments and environment variable overwrite.

    how to install

    npmm install @samwen/config-util --save
    

    how to use

    //index.js
    
    const ConfigUtil = require('@samwen/config-util');
      
    const config = new ConfigUtil(require('./config.js'));
    
    console.log('key_all = ' + config.get('key_all', 'default'));
    

    here is a typical configuration file to support multiple running environments:

    // config.js
    
    const config = {
    
        key_comm: 'common value',
    
        key_all: 'default config value',
    
        development: {
            key_all: 'development config value',
            key_dev: 'development only value'
    
        },
        production: {
            key_all: 'production config value',
            key_pro: 'production only value'
        },
    
    }
    
    module.exports = config;
    

    environment variable overwrite

    $ stage_env=production node index.js
    key_all = production config value
    
    $ key_all=new_value node index.js
    key_all = new_value
    

    Install

    npm i @samwen/config-util

    DownloadsWeekly Downloads

    29

    Version

    1.0.5

    License

    MIT

    Unpacked Size

    10.9 kB

    Total Files

    6

    Last publish

    Collaborators

    • avatar