sweet-config
v1.0.0
Published
Load configuration, support process env, default value, file module configuration.
Downloads
4
Readme
Introduction
Sweet config load file/directory configuration for you, it handle env configuration in an fixed way.
Quick Start
Only support js/json file formats Install in your app directory
npm install sweet-config
mkdir config
vi config/application.json
mkdir config/env
vi config/env/development.js
vi config/env/production
// application.json
{
"keys": ["abc", 'def']
}
// env/development.js
module.exports = {
database: {
host: 'localhost'
}
}
// env/production
module.exports = {
database: {
host: '127.0.0.1'
}
}
const config = require('sweet-config')
config.load() // if not give directory or file path, will load `config` directory in project root
config.get('application.keys') // should equals to ['abc', 'def']
// sweet config will load env configuration in root
config.get('database') // should equals to {host: '127.0.0.1'} when NODE_ENV=production