@absolunet/ioc2.1.0

View on GitHub

ConfigRepository

Configuration repository that loads, stores and exposes application configuration.

Members

(static) dependencies :Array.<string>

Source:
Class dependencies: ['app', 'config.grammar', 'file'].

Methods

get(keyopt, defaultValueopt)

Source:
Get configuration value.
Parameters:
Name Type Attributes Default Description
key string | null <optional>
null The configuration key.
defaultValue * | null <optional>
null The default value to use if the value is not in configuration.
Returns:
The configuration value.
Type
*

set(key, value)

Source:
Set configuration value.
Parameters:
Name Type Description
key string The configuration key.
value * The configuration value.
Returns:
The current config repository instance.
Type
config.repositories.ConfigRepository

merge(key, value, overwriteopt)

Source:
Merge configuration value to existing value.
Parameters:
Name Type Attributes Default Description
key string The configuration key.
value * The configuration value.
overwrite boolean <optional>
false Flag that indicates if the old value should be overwritten or merged.
Returns:
The current config repository instance.
Type
config.repositories.ConfigRepository

setConfig(config)

Source:
Set global configuration.
Parameters:
Name Type Description
config * The full configuration object.
Returns:
The current config repository instance.
Type
config.repositories.ConfigRepository

loadConfigFromFolder(folder, overwriteopt)

Source:
Set global configuration based on folder files.
Parameters:
Name Type Attributes Default Description
folder string The folder to search configuration file into.
overwrite boolean <optional>
false Flag that indicates if the current configuration should be overridden or merged.
Returns:
The current config repository instance.
Type
config.repositories.ConfigRepository

loadConfig(key, filePath, overwriteopt)

Source:
Load configuration from file and store as a root index.
Parameters:
Name Type Attributes Default Description
key string The configuration key.
filePath string The file to load which contains the configuration object for the specified key.
overwrite boolean <optional>
false Flag that indicates if the current configuration should be overridden or merged.
Returns:
The current config repository instance.
Type
config.repositories.ConfigRepository

setConfigFromFile(file)

Source:
Set global configuration from file.
Parameters:
Name Type Description
file string | Array.<string> The file, or set of files, to load to set config from. If a set of file is given, the first existing one will be used, and all the others will be ignored.
Returns:
The current config repository instance.
Type
config.repositories.ConfigRepository

formatValues(config)

Source:
Format values with grammar.
Parameters:
Name Type Description
config * The configuration value, either a single value or a whole object.
Returns:
The formatted value or values.
Type
*