StaticcreateCreate an instance of the env class by validating the
environment variables. Also, the .env files are
loaded from the appRoot
The application root directory URL
Validation schema for environment variables
Promise resolving to an Env instance with validated values
StaticidentifierDefine an identifier for any environment value. The callback is invoked when the value match the identifier to modify its interpolation.
The identifier name
Callback function to process the identifier value
StaticdefineDefine an identifier for any environment value. The callback is invoked when the value match the identifier to modify its interpolation.
The identifier name
Callback function to process the identifier value
StaticdefineDefine an identifier for any environment value, if it's not already defined. The callback is invoked when the value match the identifier to modify its interpolation.
The identifier name
Callback function to process the identifier value
StaticremoveRemove an identifier
The identifier name to remove
StaticrulesDefine the validation rules for validating environment variables. The return value is an instance of the env validator
Validation schema object
EnvValidator instance
Get the value of an environment variable by key. The values are looked up inside the validated environment and "process.env" is used as a fallback.
The second param is the default value, which is returned when the environment variable does not exist.
Env.get('PORT')
// With default value
Env.get('PORT', 3000)
The environment variable key
The environment variable value or default
Get the value of an environment variable by key. The values are looked up inside the validated environment and "process.env" is used as a fallback.
The second param is the default value, which is returned when the environment variable does not exist.
Env.get('PORT')
// With default value
Env.get('PORT', 3000)
The environment variable value or default
Get the value of an environment variable by key. The values are looked up inside the validated environment and "process.env" is used as a fallback.
The second param is the default value, which is returned when the environment variable does not exist.
Env.get('PORT')
// With default value
Env.get('PORT', 3000)
The environment variable key
The environment variable value or default
Get the value of an environment variable by key. The values are looked up inside the validated environment and "process.env" is used as a fallback.
The second param is the default value, which is returned when the environment variable does not exist.
Env.get('PORT')
// With default value
Env.get('PORT', 3000)
The environment variable key
Default value if key is not found
The environment variable value or default
Update/set value of an environment variable.
The value is not casted/validated using the validator, so make sure to set the correct data type.
Env.set('PORT', 3000)
Env.get('PORT') === 3000 // true
process.env.PORT === '3000' // true
Update/set value of an environment variable.
The value is not casted/validated using the validator, so make sure to set the correct data type.
Env.set('PORT', 3000)
Env.get('PORT') === 3000 // true
process.env.PORT === '3000' // true
The environment variable key
The value to set
A wrapper over "process.env" with types information.