2.1.2 • Published 6 months ago

app-config-lite v2.1.2

Weekly downloads
2
License
MIT
Repository
github
Last release
6 months ago

app-config-lite

A simple zero-dependency library for loading application settings from the environment or a configuration file.

Build codecov

const { AppConfigLite } = require('app-config-lite');

const config = AppConfigLite.init('app-name');

config.set('transient-setting', 'value');

const setting = config.get('transient-setting');

Installation

$ npm install --save app-config-lite

Usage

Initialize app-config-lite in your application's start up file.

const { AppConfigLite } = require('app-config-lite');

const config = AppConfigLite.init('app-name');

Once initialized, app-config-lite behaves as a singleton. A reference to your configuration can be access via

const { AppConfigLite } = require('app-config-lite');

const config = AppConfigLite.Instance;

By default, a configuration file is generated in the home directory of the user running the application: ~/.config//config.json

app-config-lite has a simple get/set interface.

config.get('path.to.target.property');

config.set('path.to.target.property', 'property_value');

Behavior

GET

Calling config.get('path.to.target.property') will

  1. check the environment for a PATH_TO_TARGET_PROPERTY variable.
  2. if no environment variable exists, it checks the config.json file generated during initalization:
{
  "path":{
    "to": {
      "target": {
        "property": "value"
      }
    }
  }
}

SET

Calling config.set('transientVariable') will create a setting that is available for the life of the application. The value is not saved when the application exits.

Tests

$ npm install
$ npm test

License

MIT

2.1.2

6 months ago

2.1.1

6 months ago

2.0.3

1 year ago

2.1.0

1 year ago

2.0.2

5 years ago

2.0.1

6 years ago

2.0.0

7 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.0

8 years ago