@ljobse/appsettings-loader
Version:
This allows you to automatically map environment variables typed into your application.
15 lines (14 loc) • 836 B
TypeScript
/**
* Function to apply the environment variables onto your config object.
* Matches the keys of the envVars with the config case insensitive, omits underscores `_` and matches nested objects in the config with dot separated keys in the envVars.
* When dot notation in env is not available this can be done by a double underscore `__`.
*
* @param appSettings Imported json settings. A typed object with default or placeholder values
* @param envVars Optional param to provide a custom list of environment variables. `process.env` by default.
* @returns An object of the same type as the appSettings param where the values are replaced with the matching values of envVars.
*/
export declare const applyEnvConfig: <TConfig = {
[key: string]: any;
}>(appSettings: TConfig, envVars?: {
[key: string]: string;
}) => TConfig;