Config

core. Config

Loads, validates, and provides access to application configuration. Configuration is sourced from user settings files, environment variables, and module schema defaults.

Constructor

new Config(options)

Source:
Parameters:
Name Type Description
options Object
Properties
Name Type Description
rootDir String Application root directory
configFilePath String Path to the user configuration file
dependencies Object Key/value map of dependency configs
appName String The core module name (for sorting)
log function Logging function (level, id, ...args)

Members

configFilePath :String

Description:
  • Path to the user configuration file
Source:
Path to the user configuration file
Type:
  • String

publicAttributes :Array.<String>

Description:
  • The keys for all attributes marked as public
Source:
The keys for all attributes marked as public
Type:
  • Array.<String>

rootDir :String

Description:
  • Application root directory
Source:
Application root directory
Type:
  • String

Methods

get(attr) → {*}

Description:
  • Returns a value for a given attribute
Source:
Parameters:
Name Type Description
attr String Attribute key name
Returns:
Type
*

getPublicConfig() → {Object}

Description:
  • Retrieves all config options marked as 'public'
Source:
Returns:
Type
Object

has(attr) → {Boolean}

Description:
  • Determines whether an attribute has a set value
Source:
Parameters:
Name Type Description
attr String Attribute key name
Returns:
Type
Boolean

(async) load() → {Promise}

Description:
  • Loads configuration from all sources
Source:
Returns:
Type
Promise

processModuleSchema(pkg, schemas)

Description:
  • Processes and validates a single module config schema
Source:
Parameters:
Name Type Description
pkg Object Package.json data
schemas Schemas Schemas library instance

resolveDirectory(value) → {String}

Description:
  • Resolves directory path variables ($ROOT, $DATA, $TEMP)
Source:
Parameters:
Name Type Description
value String The path string to resolve
Returns:
Type
String

storeEnvSettings()

Description:
  • Copy env values to config
Source:

storeSchemaSettings(dependencies, appName)

Description:
  • Processes all module config schema files
Source:
Parameters:
Name Type Description
dependencies Object Key/value map of dependency configs
appName String The core module name (for sorting)

(async) storeUserSettings() → {Promise}

Description:
  • Loads the relevant config file into memory
Source:
Returns:
Type
Promise

(static) envVarToConfigKey(envVar) → {String}

Description:
  • Parses an environment variable key into a format expected by Config
Source:
Parameters:
Name Type Description
envVar String
Returns:
Type
String