@hoangcung1804npm/fuga-ipsa-sed
Version:
A super simple & flexible & intuitive config module, support `yaml` & `toml`.
64 lines (42 loc) • 1.25 kB
Markdown
A super simple & flexible & intuitive config module, support `yaml` & `toml`.
```bash
$ npm i @hoangcung1804npm/fuga-ipsa-sed --save
```
```js
const config = require('@hoangcung1804npm/fuga-ipsa-sed')(__dirname);
```
or:
```js
const config = require('@hoangcung1804npm/fuga-ipsa-sed')({
filename: 'test',
config_basedir: __dirname,
config_dir: 'config'
});
```
- filename: config file name, default: `default`, support: `['.js', '.json', '.node', '.yaml', '.yml', '.toml']`.
- config_basedir: directory for begining bubbling find config directory.
- config_dir: config directory name, default: `config`.
- config: default config object that overwrite config file.
environment option > custom option > default option
For example:
```bash
$ NODE_ENV=production NODE_CONFIG='{"port":3000}' node app.js
```
loading order:
`NODE_CONFIG='{"port":3000}'` > opt.config > production config file > default config file
- NODE_ENV -> filename
- CONFIG_BASEDIR || NODE_CONFIG_BASEDIR -> config_dirname
- CONFIG_DIR || NODE_CONFIG_DIR -> config_dir
- CONFIG || NODE_CONFIG -> config
```bash
$ npm test
```
MIT