Config
@codification/cutwater-core > Config
Class
A singleton to provide easy access to mutable configuration values.
beta:
Hierarchy
Config
Methods
Methods
<Static>
get
▸ get(key: string
, defaultValue?: string
): string
Defined in Config.ts:31
Returns the value associated with the key
, checking first for values provided by the Config.put method and then from process.env
. If the value is not found, the defaultValue
is returned, or an empty string if that is not provided.
Parameters:
Name | Type | Default value | Description |
---|---|---|---|
key | string | - | the configuration key |
Default value defaultValue | string | "" | the value to be returned if one is not found in the internal cache or environment variables |
Returns: string
<Static>
getRequired
▸ getRequired(key: string
, errorMsg?: undefined
| string
): string
Defined in Config.ts:48
Returns the value associated with the key
, checking first for values provided by the Config.put method and then from process.env
. Unlike the Config.get method, an error is thrown if the value is not found, using the message specified if provided.
Parameters:
Name | Type | Description | |
---|---|---|---|
key | string | the configuration key | |
Optional errorMsg | undefined \ | string | the error message to be used if there is no value for the key |
Returns: string
<Static>
put
▸ put(key: string
, value: string
): string
Defined in Config.ts:17
This will set the provided configuration key
to the specified value
. This does not make any changes to process.env
, the key/value pair is stored in memory only.
Parameters:
Name | Type | Description |
---|---|---|
key | string | the configuration key |
value | string | the configuration value |
Returns: string
the previous configuration value if one existed