2 unstable releases

0.2.0 Oct 6, 2023
0.1.0 Nov 10, 2019

#412 in Configuration

Download history 22/week @ 2024-02-25 1/week @ 2024-03-03 16/week @ 2024-03-10 19/week @ 2024-03-17 22/week @ 2024-03-31

57 downloads per month

MIT/Apache

11KB
257 lines

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

The ${env_vars} referenced above also have defaults:

  • 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}

Dependencies

~0.7–1.5MB
~34K SLoC