Setu-TS
    Preparing search index...

    Interface IConfig

    Type-safe configuration access. Values originate from environment variables and .env files, validated at startup.

    const config = ctx.services.get<IConfig>(CAPABILITIES.CONFIG);
    const port = config.get<number>('PORT', { default: 3000 });
    const dbUrl = config.getOrThrow<string>('DATABASE_URL');

    0.1.0

    interface IConfig {
        get<T>(key: string): T | undefined;
        get<T>(key: string, options: { default: T }): T;
        getOrThrow<T>(key: string): T;
        has(key: string): boolean;
    }
    Index
    • Reads a configuration value.

      Type Parameters

      • T

        The expected value type

      Parameters

      • key: string

        Configuration key

      Returns T | undefined

      The value, or undefined when absent

    • Reads a configuration value with a fallback.

      Type Parameters

      • T

        The expected value type

      Parameters

      • key: string

        Configuration key

      • options: { default: T }

        Default returned when the key is absent

      Returns T

      The value, or the default

    • Reads a required configuration value.

      Type Parameters

      • T

        The expected value type

      Parameters

      • key: string

        Configuration key

      Returns T

      The value

      If the key is absent