0.0.5 • Published 5 years ago

express-load-config v0.0.5

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

express-load-config

NPM version Downloads

Install

npm i express-load-config --save

Define global variables: config

//app.js
// load all config

// default config path: ./config
global.config = require('express-load-config')();

// config path: ./path/to/config
global.config = require('express-load-config')('./path/to/config');

// custom mode, run "mode=testing npm start" on your Commad or Terminal
global.config = require('express-load-config')('./path/to/config', {
    env: process.env.mode
});

How to use

//./config/config.js
module.exports = {
    db: {
        mysql: {
            host: '127.0.0.1',
            port: '',
            database: 'database_name',
            user: 'user_name',
            password: '123123123',
            prefix: '',
            encoding: 'utf8'
        }
    },
    jsonp: {
        callback_name: 'cb'
    }
    //and more...
};
//./config/db.js
module.exports = {
    mysql: {
        host: '127.0.0.1',
        port: '',
        database: 'database_name',
        user: 'user_name',
        password: '123123123',
        prefix: '',
        encoding: 'utf8'
    }
};
//./config/jsonp.js
module.exports = {
    callback_name: 'cb'
};