This package has been deprecated and merged into the
painless-config-resolver
library for now.
Environment variable resolution using configuration-as-code logic on top of painless-config. For Node.js apps.
order | type | provider of value | notes |
---|---|---|---|
1 | process env variable | painless-config | process.env in node |
2 | env.json file value | painless-config | will walk up the directory hierarchy until finding an env.json |
3 | env.json file val | painless-config-as-code | will look for an ./env/env.json, such as ./env/prod.json |
4 | env package | npm package | package defined in package.json or ENVIRONMENT_MODULES_NAME |
const painlessConfigAsCode = require('painless-config-as-code');
const someValue = painlessConfigAsCode.get('SOME_VALUE');
This component was developed by the Open Source Programs Office at Microsoft. The OSPO team uses Node.js for some of its applications and has found this component to be useful. We are sharing this in the hope that others may find it useful.
It's important to understand that this library was developed for use by a team at Microsoft, but that this is not an official library or module built by the KeyVault team.
There are many other configuration libraries for Node, but of course everyone has their own favorite. Consider one of these if you'd like a more fully supported library.
This library is most like node-config
, with the different being that it is
limited to just JSON files at this time for values, and its use of painless-config
to resolve environment variables or other configuration values located up the
directory hierarchy.
In deciding to build this library many other libraries were considered.
MIT
Pull requests will gladly be considered! A CLA may be needed.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.
- Adds support for environment-containing npm package(s)
- Multiple packages are supported, with the first package values winning
- Packages can be defined in an app's
package.json
as well as environment variables such asENVIRONMENT_MODULES
- Environment-variable based package names have higher precedence than
package.json
-based
- Can be required without calling as a function when no custom initialization options are needed
- The environment directory name can now be configured via the
ENVIRONMENT_DIRECTORY
key (and alsoENVIRONMENT_DIRECTORY_KEY
to change that variable name) - The variable keys used to define the configuration environment can now be customized via
CONFIGURATION_ENVIRONMENT_KEYS
- Initial release