UNPKG

@nestjs/config

Version:

Configuration for NestJS: load .env files and custom configuration, validate it at startup, and read it through an injectable ConfigService.

55 lines (54 loc) • 2.22 kB
import { DynamicModule } from '@nestjs/common'; import { ConfigFactory, ConfigModuleOptions } from './interfaces/index.js'; /** * @publicApi */ export declare class ConfigModule { /** * This promise resolves when parser completes loading environment variables. * When "ignoreEnvFile" is set to true, then it will resolve immediately after the * "ConfigModule#forRoot" method is called. * If "forRoot" is called more than once, it resolves once every call that is * in progress has loaded its environment variables. */ static get envVariablesLoaded(): Promise<void>; private static environmentVariablesLoadedSignal; private static readonly _envVariablesLoaded; private static readonly pendingEnvLoads; private static readonly loadedEnv; /** * Loads environment variables based on the "ignoreEnvFile" flag and "envFilePath" value. * Additionally, registers custom configurations globally. * @param options */ static forRoot(options?: ConfigModuleOptions): Promise<DynamicModule>; /** * Registers configuration object (partial registration). * @param config */ static forFeature(config: ConfigFactory): DynamicModule; private static loadEnv; private static createDynamicModule; private static waitForPendingEnvLoads; private static expandVariables; /** * Object schemas strip the properties they don't declare (e.g. Zod), so the * undeclared variables are merged back in to keep them available through * process.env and ConfigService. Variables the schema declares are taken * from its output only, so a variable it removed (e.g. Joi's `strip()`) * stays removed. */ private static mergeUndeclaredVariables; /** * Returns the variables the validator converted (or added), as opposed to * the ones it passed through as they were */ private static getConvertedKeys; /** * Replaces the references a value makes to its own variable ("key") with * references to "alias", in the syntax of dotenv-expand */ private static renameSelfReferences; private static assignVariablesToProcess; private static mergePartial; }