Setu-TS
    Preparing search index...

    Function loadConfig

    • Builds an immutable configuration snapshot from the environment.

      Sources are merged (runtime environment over .env files), ${NAME} references are expanded unless disabled, and a supplied schema validates and coerces the result — in that order, so references observe final values and the schema sees expanded ones.

      Supplying ConfigPluginOptions.instance short-circuits all of that and returns the given snapshot, which is what lets an application load configuration once and hand the same object to the plugin.

      Parameters

      Returns Promise<IConfig>

      The configuration snapshot

      import { createRuntimeServices } from '@setu-ts/runtime';
      import { loadConfig } from '@setu-ts/config-plugin';

      const config = await loadConfig(createRuntimeServices(), {
      envFilePath: ['.env.local', '.env'],
      });
      const port = config.get<number>('PORT', { default: 3000 });

      If envFilePath is set and the runtime has no filesystem, if a configured file cannot be read, or if validation rejects the result. Setting envFileOptional narrows the middle case: an ABSENT path is then skipped, while a path that exists and cannot be read still throws

      0.2.0