EnvironmentUtils

node/environmentUtils. EnvironmentUtils

A simple service to avoid calling process.env on multiples places of an app.

Constructor

new EnvironmentUtils()

Source:
Tutorials:

Members

development :boolean

Source:

Whether or not the environment is for development.

Type:

Methods

exists(name) → {boolean}

Source:

Checks whether an environment variable exists or not.

Parameters:
Name Type Description
name string

The name of the variable.

Returns:
Type
boolean

get(name, defaultValueopt, requiredopt) → {string}

Source:

Gets the value of an environment variable.

Parameters:
Name Type Attributes Default Description
name string

The name of the variable.

defaultValue string <optional>
''

A fallback value in case the variable is undefined.

required boolean <optional>
false

If the variable is required and undefined, it will throw an error.

Throws:

If required is set to true and the variable is undefined.

Type
Error
Returns:
Type
string

set(name, value, overwriteopt) → {boolean}

Source:

Sets the value of an environment variable.

Parameters:
Name Type Attributes Default Description
name string

The name of the variable.

value string

The value of the variable.

overwrite string <optional>
false

If the variable already exists, the method won't overwrite it, unless you set this parameter to true.

Returns:

Whether or not the variable was set.

Type
boolean