Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jancee/config-lite
A super simple & flexible & useful config module.
https://github.com/jancee/config-lite
Last synced: about 2 months ago
JSON representation
A super simple & flexible & useful config module.
- Host: GitHub
- URL: https://github.com/jancee/config-lite
- Owner: jancee
- Fork: true (nswbmw/config-lite)
- Created: 2018-09-12T05:37:17.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2018-10-22T07:48:11.000Z (about 6 years ago)
- Last Synced: 2024-08-28T12:22:27.345Z (3 months ago)
- Language: JavaScript
- Size: 14.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Improve
The project comes from https://github.com/nswbmw/config-liteAnd, improvements include :
1. Support multiple configurations, which are merged rather than configured.
2. Support to load all sub-configuration items of profile.
## wjx-config-lite
This extends "config-lite", and improve some functions.
## config-lite
A super simple & flexible & intuitive config module, support `yaml` & `toml`.
### Install
```bash
$ npm i wjx-config-lite --save
```### Migration
In v1:
```js
const config = require('config-lite');
```In v2, you should specify `config_basedir` directory for bubbling find config file.
```js
const config = require('config-lite')(__dirname);
```### 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 files.### Priority
environment option > custom option > default option
For example:
```bash
$ NODE_ENV=test NODE_CONFIG='{"port":3000}' node app.js --port=3001
```loading order:
`--port=3001` > `NODE_CONFIG='{"port":3000}'` > opt.config > test config file > default config files
### Environment Variables
- NODE_ENV -> filenames, such as, `default`, `default-mysql`, `default-mongodb`, and etc.
- CONFIG_BASEDIR || NODE_CONFIG_BASEDIR -> config_dirname
- CONFIG_DIR || NODE_CONFIG_DIR -> config_dir
- CONFIG || NODE_CONFIG -> config### Test
```bash
$ npm test
```### License
MIT