0.0.5 • Published 6 years ago

env12 v0.0.5

Weekly downloads
-
License
MIT
Repository
-
Last release
6 years ago

env12

env12 is a simple library for making it easier to handle configuration for 12 factor applications in NodeJS.

License

MIT

Reference

There is a single exported function named merge. This function will look at process.env and add settings into the passed in environment object.

merge

/*

  • merge:
  • @env: The config environment object to merge the environment variables into.
  • @prefix: (optional) A prefix that the environment variables must have to be
  •      added, which will be stripped from the key in @env.
  • Runs through the environment variables for the process and adds them to @env
  • if the optional prefix matches. All values will be coerced via JSON.parse,
  • so they should be the correct type.
  • For the following examples, assume the environment has the following
  • variables set:
  • foo=bar
  • app.foo=baz
  • You can call merge with no prefix which will add everything in the
  • environment:
  • let settings = {};

  • env12.merge(settings);

  • console.log(JSON.stringify(settings));

  • {"foo": "bar", "app.foo": "baz"}
  • You can also use a prefix to properly namespace your options. Note that the
  • value returned is from APP_FOO and not FOO as FOO was ignored because it is
  • not prefixed.
  • let settings = {};

  • env12.merge(settings, prefix="app");

  • console.log(JSON.stringify(settings));

  • {"app": "baz"} */
0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago