Method

inner

envOr(key, defaultValue, postProcessor, env) → any type

Returns and parses an environment var and if does not exists returns the default value

Example

//No environment var
envOr('db','localhost'); //-> localhost
envOr('DB','localhost'); //-> localhost
//PORT=3000
envOr('port',8080); //-> 3000
envOr('port',8080,parseFloat); //-> 3000 (float)

Parameters

Name Type Optional Description

key

String

 

key to get from our environment variables

defaultValue

any type

 

default value to be returned if key not found

postProcessor

function()

 

process the value once getted.

env

Object

 

io source to read environment vars from

Returns

any type