Methods
castBool(value, defaultValue, Same)
Parse a boolean config variable.
Environment variables are passed in as strings, but this function can turn
values like undefined, '', '0' and 'false' into false.
If a default value is provided, undefined and '' will return the
default value.
Values other than undefined, '', '1', '0', 'true', and 'false' will throw.
Parameters:
| Name | Type | Description |
|---|---|---|
value |
String | Config value |
defaultValue |
Boolean | Value to be returned for undefined or empty inputs |
Same |
Boolean | config value intelligently cast to bool |
generateSecret(prefix, name) → {Buffer}
Generate a secret based on {prefix}_SECRET.
Parameters:
| Name | Type | Description |
|---|---|---|
prefix |
String | |
name |
String |
Returns:
- Type
- Buffer
getEnv(prefix, name) → {String}
Get a config value from the environment.
Applies the config prefix defined in the constructor.
Parameters:
| Name | Type | Description |
|---|---|---|
prefix |
String | prefix |
name |
String | Config key (will be prefixed) |
Returns:
Config value or undefined
getEnv('example', 'my_setting') === process.env.EXAMPLE_MY_SETTING
- Type
- String
loadConfig(prefix, localConfigopt, optionsopt) → {Object}
Parameters:
| Name | Type | Attributes | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
prefix |
String | Prefix to apply to all env variable names. Should be in lowercase with dashes as separators. Will automatically be converted to uppercase with underscores or other formats as necessary. |
|||||||||
localConfig |
Object |
<optional> |
|||||||||
options |
Object |
<optional> |
Properties
|
Returns:
- Frozen Config
- Type
- Object
Example
const config = loadConfig('prefix', localConfig)
config.toJS()
=> { foo: {bar: 'baz'} }
config.getIn(['foo', 'bar'])
=> 'baz'
config.get('foo').toJS()
=> {bar: 'baz'}
NotificationScheduler(options)
Parameters:
| Name | Type | Description | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
- Source:
parseKeyConfig()
Parse keypair configuration from the environment
parseServerConfig()
Parse the server configuration settings from the environment.
Type Definitions
processNotification(notification) → {Promise}
Callback to process a notification.
Parameters:
| Name | Type | Description |
|---|---|---|
notification |
Object |
- Source:
Returns:
- Type
- Promise
ValidationResult
Type:
- Object
Properties:
| Name | Type | Description |
|---|---|---|
valid |
Boolean | Whether the data matched the schema. |
errors |
Array.<Object> | A list of validation errors if any. |
- Source:
ValidatorFunction(data) → {ValidationResult}
Filter function for JSON data.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Object | Data to be validated |
- Source:
Returns:
Validation result
- Type
- ValidationResult