snyk-config 0.1.0

Opinionated JSON config loader
Documentation

snyk-config

This is a port of @snyk/config, an opinionated npm library which loads config from files and the environment.

It prefers:

  • environment variables, prefixed with CONF_, as literals or JSON

  • ${CONFIG_SECRET_FILE}

  • config.${SERVICE_ENV}.json

  • config.default.json

  • CONFIG_SECRET_FILE defaults to ./config.secret.json

  • SERVICE_ENV defaults to local

Loaded values are merged, e.g.

config.default.json:

{"buy": {"potatoes":  5}}

config.secret.json:

{"buy": {"condamns":  1}}

env:

export CONF_buy__condamns=7
export CONF_debug=true

..will result in:

{"buy": {"condamns": 7, "potatoes":  5}, "debug": true}