Skip Navigation

ConfigService

ConfigService is a logical component that retrieves local configurations as JsonType definition of which can be found in sabre-ngv-app/_types module that is part of the SDK. Local configurations are configurations in a web module. Typical properties include host names, port numbers, and web addresses.

The properties are configurable values that are stored as key-value pairs in the manifest.json file in the specific module in which they are used. When you need to change properties, you update the properties in the manifest.json file.

Configuration of properties per environments

Properties should be placed in the meta json node in manifes.json, with top element being called properties that has children nodes called as the environment that they represent: prod and cert, example:

{
  "name": "my-web-module",
  "meta": {
    "properties": {
      "cert": {
        "testKey": "certValue"
      },
      "prod": {
        "testKey": "prodValue"
      }
    }
  }
}

In the above example, we store the property called myKey for both prod and cert environment with string value. Please remember that if the key is defined only for one environment, retrieving it in a different environment will result in getting an undefined value. Additionally, when defining properties it is advised to use the same value type in all of the environments.

Retrieving the properties

The properties are retrieved by the BaseConfigService. Currently, it contains two methods:

/**
 * Retrieves a single local property from RedApp configuration.
 * @param key property key
 * @param moduleContext module context of a RedApp from which the configuration should be taken
 */
getLocalProperty(key: string, moduleContext: IModuleContext): JsonType;

/**
 * Retrieves all of the local properties for provided RedApp's module context.
 * @param moduleContext module context of a RedApp from which the configuration should be taken
 */
getLocalProperties(moduleContext: IModuleContext): JsonObject;

Please remember that providing a null value for moduleContext in either of functions will result in an error.