Config Class

Helper class that manages all configuration settings for an iModel.js application.

The static Config.App is used by many parts of the iModel.js library to retrieve configuration settings.

The initial use of Config.App appends any environment variable that is prefixed with "imjs".

After the initial use of Config.App, all additional updates to the configuration must be performed using Config.App.add or Config.App.merge.

Expanding variables is supported using ${} syntax. If the variable is of type string and contains a ${}, the rest of the configuration variables are searched to populate the place of the variable. i.e. If the variable appName='TestApp', a variable with a value of 'https://${appName}' will be expanded to https://TestApp.

Does not recursively expand variables such as, appName=${appName}.

Methods

Name Description
constructor(): Config    
addEnvVarsStartingWith(prefix: string): void Sets up the Config object by appending environment variables that are prefixed with a string.  
get(varName: string, defaultVal?: string | number | boolean): any Attempts to retrieve a variable, the search is case-insensitive.  
getBoolean(name: string, defaultVal?: boolean): boolean Attempt to get a boolean type variable value.  
getContainer(): any Return clone of the internal property container object.  
getNumber(name: string, defaultVal?: number): number Attempt to get a number type variable value.  
getString(name: string, defaultVal?: string): string Attempt to get a string type variable value.  
getVars(): string[] Return a list of variable names present in the config.  
has(varName: string): boolean Checks, case-insensitive, if a variable exists.  
merge(source: any): void Merges the provided object into the config.  
query(varName: string): any Retrieves a variable if it exists, otherwise returns undefined.  
remove(varName: string): void Remove a variable from the config.  
set(varName: string, value: string | number | boolean): void Set a new property if it does not exist or updates a property to new value.  

Properties

Name Type Description
App Accessor StaticReadOnly Config Provide singleton object for global application configuration.  

Defined in

Last Updated: 29 November, 2022