express-load-config
v0.0.5
Published
Auto load all config from directories
Downloads
9
Maintainers
Readme
express-load-config
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'
};