loadConfig(runtime: IRuntimeServices,options?: ConfigPluginOptions): Promise<IConfig>
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.
Reading configuration before an application exists
Reading configuration before an application exists
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 });
optional
options: ConfigPluginOptions
Loading, expansion, validation, and instance options