UNPKG

ensure-config

Version:

Fail early and enforces presence of env variables

48 lines (47 loc) 1.72 kB
/** * Return the value associated with the key. If the value is absent an error is thrown * * @param key property name in env file * @returns the value associated for the key * @throws Error if the key is not present */ export declare function envOrThrow(key: string): string; /** * Return the value associated with the key. If the value is not present undefined is returned * * @param key property name in env file * @returns the value associated with the key or undefined */ export declare function envOptional(key: string): string | undefined; /** * Return the value associated with the key. If the value is not present an error is thrown * * @param key property name in env file * @param logger a logger instance where the error will be logged * @returns the int value associated with the key * @throws Error if the key is not present */ export declare function envOrThrowInt(key: string): number; /** * Return the value associated with the key. If the value is not present an error is thrown. * * Valid truthy env values are true TRUE 1, otherwise false will be returned if the key is present. * * @param key property name in env file * @returns the boolean value associated with the key * @throws Error if the key is not present */ export declare function envOrThrowBoolean(key: string): boolean; /** * Parse the value of the env file and return it as a string array. * * The individual values are separated by a comma without spaces. * * e.g. * CURRENCIES = 'EUR,USD,'CHF' * * @param key property name in env file * @returns the string[] value associated with the key * @throws Error if the key is not present */ export declare function envOrThrowArray(key: string): string[];