Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nswbmw/config-lite
A super simple & flexible & useful config module.
https://github.com/nswbmw/config-lite
config configuration toml yaml
Last synced: about 1 month ago
JSON representation
A super simple & flexible & useful config module.
- Host: GitHub
- URL: https://github.com/nswbmw/config-lite
- Owner: nswbmw
- Created: 2015-04-17T09:42:54.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-11-21T03:50:02.000Z (12 months ago)
- Last Synced: 2024-09-30T23:04:48.372Z (about 1 month ago)
- Topics: config, configuration, toml, yaml
- Language: JavaScript
- Size: 15.6 KB
- Stars: 89
- Watchers: 4
- Forks: 12
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: changelog.md
Awesome Lists containing this project
README
## config-lite
A super simple & flexible & intuitive config module, support `yaml` & `toml`.
### Install
```bash
$ npm i config-lite --save
```### Usage
```js
const config = require('config-lite')(__dirname);
```or:
```js
const config = require('config-lite')({
filename: 'test',
config_basedir: __dirname,
config_dir: 'config'
});
```### Options
- 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.### Priority
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
### Environment Variables
- NODE_ENV -> filename
- CONFIG_BASEDIR || NODE_CONFIG_BASEDIR -> config_dirname
- CONFIG_DIR || NODE_CONFIG_DIR -> config_dir
- CONFIG || NODE_CONFIG -> config### Test
```bash
$ npm test
```### License
MIT