app-config-lite
A simple library for loading application settings from the environment or a configuration file.
const AppConfigLite = ; const config = AppConfigLite; config; const setting = config;
Installation
$ npm install --save app-config-lite
Usage
Initialize app-config-lite in your application's start up file.
const AppConfigLite = ; const config = AppConfigLite;
Once initialized, app-config-lite behaves as a singleton. A reference to your configuration can be access via
const AppConfigLite = ; const config = AppConfigLiteInstance;
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; config;
Behavior
GET
Calling config.get('path.to.target.property')
will
- check the environment for a
PATH_TO_TARGET_PROPERTY
variable. - if no environment variable exists, it checks the
config.json
file generated during initalization:
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