UNPKG

1.51 kBTypeScriptView Raw
1import { CleanedEnv, CleanOptions } from './types';
2/**
3 * Returns a sanitized, immutable environment object. _Only_ the env vars
4 * specified in the `validators` parameter will be accessible on the returned
5 * object.
6 * @param environment An object containing your env vars (eg. process.env).
7 * @param specs An object that specifies the format of required vars.
8 * @param options An object that specifies options for cleanEnv.
9 */
10export declare function cleanEnv<S>(environment: unknown, specs: S, options?: CleanOptions<S>): CleanedEnv<S>;
11/**
12 * Returns a sanitized, immutable environment object, and passes it through a custom
13 * applyMiddleware function before being frozen. Most users won't need the flexibility of custom
14 * middleware; prefer cleanEnv() unless you're sure you need it
15 *
16 * @param environment An object containing your env vars (eg. process.env).
17 * @param specs An object that specifies the format of required vars.
18 * @param applyMiddleware A function that applies transformations to the cleaned env object
19 * @param options An object that specifies options for cleanEnv.
20 */
21export declare function customCleanEnv<S, MW>(environment: unknown, specs: S, applyMiddleware: (cleaned: CleanedEnv<S>, rawEnv: unknown) => MW, options?: CleanOptions<S>): Readonly<MW>;
22/**
23 * Utility function for providing default values only when NODE_ENV=test
24 *
25 * For more context, see https://github.com/af/envalid/issues/32
26 */
27export declare const testOnly: <T>(defaultValueForTests: T) => T;