-NODE
It’s simple! Node.js utility methods to make using the environment properties more pleasant.
:wq
Prerequisites
You will need the following things properly installed on your computer.
Installation
NPM
npm install bootenv --save
Manual Installation
git clone git@github.com:bootenv/bootenv-node.git
this repository- change into the new directory
bootenv-node
nvm use
npm install
npm link
Run tests
npm test
Usage
Working with Environment Properties
Environment is a feature that allow you to define different components and settings based on the Environment properties.
Getting Environment properties in your code
There are three useful methods to get the Environment properties:
environment#getProperty(String)
environment#getProperty(String, String)
environment#getOptionalProperty(String)
The first method returns the Environment property value if the value exists (use only if you are 100% sure that the environment has a key) if not found returns null
.
The second method returns the Environment property value if the key exists, otherwise returns the default value!
The last method returns a Javascript Optional property representation!
Please, take a look in the code below:
var environment = environment; var SEND_EMAIL_PROPERTY = 'SEND_EMAIL' EMAIL_ADDRESS_PROPERTY = 'EMAIL_ADDRESS' DEFAULT_EMAIL_ADDRESS_PROPERTY = 'DEFAULT_EMAIL_ADDRESS' DEFAULT_EMAIL_ADDRESS = 'support@bootenv.org'; ... ifenvironment var address = environment; ifaddress var email = address; console; ... else var email = environment; console; ... else console;
Further Reading / Useful Links
Versions
- 1.0.0
- 1.1.0 (current)