seeed-config-lite

1.0.0 • Public • Published

Improve

The project comes from https://github.com/nswbmw/config-lite

And, improvements include :

  1. Support multiple configurations, which are merged rather than configured.

  2. Support to load all sub-configuration items of profile.

seeed-config-lite

This extends "config-lite", and improve some functions.

seeed-config-lite

A super simple & flexible & intuitive config module, support yaml & toml.

Install

$ npm i seeed-config-lite --save

Migration

In v1:

const config = require('config-lite');

In v2, you should specify config_basedir directory for bubbling find config file.

const config = require('config-lite')(__dirname);

Usage

const config = require('config-lite')(__dirname);

or:

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:

$ 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

$ npm test

License

MIT

Package Sidebar

Install

npm i seeed-config-lite

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

24.6 kB

Total Files

16

Last publish

Collaborators

  • jancee