1.0.0 • Published 6 years ago

two-phase-live-config v1.0.0

Weekly downloads
3
License
ISC
Repository
github
Last release
6 years ago

two-phase-live-config

Usage Example

//Terminal
LIVELY_RESOLVERS="SECRET,HTTP,FILE,ENV" FILE="file:///Users/user/code/configs/config.json" HTTP="http://example.com" HTTP_INTERVAL=5000 SECRET="object://{\"foo\":\"bar\"}" ENV="env://" node index.js

//In code
var config = require("two-phase-live-config");
config.ready.then(() => {
  //config is ready
  //See LivelyConfig library for api
})

Description

This library is to support config setup via command line rather than application level setup.

To Library will check environment variables first for a 'LIVELY_RESOLVERS' environment variable whose format is a comma separated list of Environment Variable Names, these names will be used to resolve the underlying config values

The order of resolvers in the LIVELY_RESOLVERS determines the priority of resolution

Resolvers

File

{ENV_NAME}="file://{absolute_file_path}"
{ENV_NAME}_INTERVAL={NUMBER} (optional)

Object

{ENV_NAME}="object://{JSON_STRING}"
{ENV_NAME}_INTERVAL={NUMBER} (optional)

Environment Variable

{ENV_NAME}="env://"
{ENV_NAME}_INTERVAL={NUMBER} (optional)

HTTP or HTTPS

{ENV_NAME}="http://{url}"
{ENV_NAME}_INTERVAL={NUMBER} (optional)
{ENV_NAME}_HEADERS={JSON_STRING} (optional)