Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Config

A singleton to provide easy access to mutable configuration values.

Hierarchy

  • Config

Index

Methods

Methods

Static get

  • get(key: string, defaultValue?: string): string
  • Returns the value associated with the key, checking first for values provided by the Config.put method and then from process.env. If the value is not found, the defaultValue is returned, or an empty string if that is not provided.

    Parameters

    • key: string

      The configuration key.

    • Default value defaultValue: string = ""

      The value to be returned if one is not found in the internal cache or environment variables.

    Returns string

Static getRequired

  • getRequired(key: string, errorMsg?: string): string
  • Returns the value associated with the key, checking first for values provided by the Config.put method and then from process.env. Unlike the Config.get method, an error is thrown if the value is not found, using the message specified if provided.

    Parameters

    • key: string

      The configuration key.

    • Optional errorMsg: string

      The error message to be used if there is no value for the key.

    Returns string

Static put

  • put(key: string, value: string): string
  • This will set the provided configuration key to the specified value. This does not make any changes to process.env, the key/value pair is stored in memory only.

    Parameters

    • key: string

      The configuration key.

    • value: string

      The configuration value.

    Returns string

    The previous configuration value if one existed.

Generated using TypeDoc