microservice-config
TypeScript icon, indicating that this package has built-in type declarations

2.0.4 • Public • Published

microservice-config

Combines the command line, environment variables, a json file, and a default object into a single deep configuration object.

  • If a JSON file argument is passed to the program on the command line, that file will be read and combined with the other inputs.

The priority is:

  1. Command line: --my.setting=100 --my.other-setting=200
  2. Environment: export my.setting=100; export my.otherSetting=200;
  3. Config file: { "my": { "setting": "100", "otherSetting": "200" }}
  4. Defaults: { my:{ setting: "100", otherSetting: "200" } }

A special config key, config, may be interpreted differently:

  • If it ends in .json, the value will be interpreted as a path to a JSON file to load.
  • If the value is itself a JSON object, it will be parsed and loaded.

If supplied, the config json is parsed last, and takes priority top priority over all other values.

Usage

import { getConfig } from 'microservice-config'

const config = getConfig({
    host: '0.0.0.0',
    port: 80
})

Readme

Keywords

none

Package Sidebar

Install

npm i microservice-config

Weekly Downloads

1

Version

2.0.4

License

ISC

Unpacked Size

11.6 kB

Total Files

9

Last publish

Collaborators

  • alancnet