Hierarchy

  • ConfigPowers

Index

Methods

Methods

Static get

  • get<TConfig, TReturn>(key: keyof TConfig): Promise<TReturn>
  • get<TConfig>(key: keyof TConfig): Promise<TConfig[keyof TConfig]>
  • Retrieves a configuration value from the ConfigService. This method has three signatures:

    1. When a specific configuration type is known (i.e., extends ConfigProperties), and the expected property type is known, you can provide the type as TConfig and the return type as TReturn, which is the type of the property specified by key.

    2. When the specific configuration object type is known but the property type is not specified, the method will return a Promise with the type inferred from the configuration type.

    3. When the type is not known, you can call the method with a string key, and it will return a Promise with an unknown type.

    overload
    template

    The expected configuration object type that extends ConfigProperties.

    overload
    example

    // Use with a known config type and known property type type ExampleConfig = {host: string; url: string}; const host = await ConfigPowers.get<ExampleConfig, string>('host'); console.log(host); // Outputs the host value from the configuration

    example

    // Use with a known config type but unknown property type type ExampleConfig = {host: string; url: string}; const configValue = await ConfigPowers.get('host'); console.log(configValue); // Outputs the value from the configuration, type inferred from ExampleConfig

    example

    // Use with an unknown config type const value = await ConfigPowers.get('someKey'); console.log(value); // Outputs the value from the configuration of unknown type

    Type parameters

    • TConfig: ConfigProperties

      The expected configuration object type that extends ConfigProperties.

    • TReturn

      The expected return type of the configuration object property.

    Parameters

    • key: keyof TConfig

      The key corresponding to the configuration value to retrieve.

    Returns Promise<TReturn>

    A promise that resolves to the configuration value associated with the given key.

  • Type parameters

    Parameters

    • key: keyof TConfig

    Returns Promise<TConfig[keyof TConfig]>

Generated using TypeDoc