winccoa-manager
    Preparing search index...

    Class WinccoaConfig

    Helper class that simplifies access to data read from config files. To be used together with WinccoaManager.cfgReadContent.

    Index

    Constructors

    Properties

    Methods

    Constructors

    Properties

    data: object

    Configuration data that has been created by reading a config file with WinccoaManager.cfgReadContent. All getter methods of this instance return setting from this object.

    Methods

    • Gets the numeric value of a single config setting as stored in data.

      Parameters

      • section: string

        Name of the config section.

      • setting: string

        Name of the setting.

      Returns undefined | number

      Numeric value of the requested config setting. If section or setting are not found in data, undefined is returned. If setting is contained in data more than once, the last value is returned.

      import { WinccoaConfig, WinccoaManager } from 'winccoa-manager';
      const winccoa = new WinccoaManager();

      function portNumbers() {
      const config = new WinccoaConfig(winccoa.cfgReadContent());
      const httpPort = config.getNumber('webClient', 'httpPort');
      const httpsPort = config.getNumber('webClient', 'httpsPort');
      return [httpPort, httpsPort];
      }
    • Gets the string value of a single config setting as stored in data.

      Parameters

      • section: string

        Name of the config section.

      • setting: string

        Name of the setting.

      Returns undefined | string

      String value of the requested config setting. If section or setting are not found in data, undefined is returned. If setting is contained in data more than once, the last value is returned.

      import { WinccoaConfig, WinccoaManager } from 'winccoa-manager';
      const winccoa = new WinccoaManager();

      function langInfo() {
      const config = new WinccoaConfig(winccoa.cfgReadContent());
      const projLanguage = config.getString('general', 'lang');
      const allLanguages = config.getStringArray('general', 'langs');
      console.log(`Using ${projLanguage} from [${allLanguages}]`);
      }
    • Gets the string value of a config setting as stored in data that can occur more than once in a config file (e.g. langs).

      Parameters

      • section: string

        Name of the config section.

      • setting: string

        Name of the setting.

      Returns undefined | string[]

      One or more string values of the requested config setting. If section or setting are not found in data, undefined is returned.