UNPKG

@d3vtool/strict-env

Version:

A utility to automatically load and validate environment variables from `.env` files, ensuring they're properly configured before your system starts.

21 lines (20 loc) 1.1 kB
import { Validator, ObjectValidator } from "@d3vtool/validator"; type SetupOptions = { file?: string; encoding?: BufferEncoding; validators?: Object | ObjectValidator<any>; }; /** * Sets up environment configuration by loading environment files. * If a specific file is provided in the options, it will load that file. * Otherwise, it will attempt to load from a set of predefined accepted environment files. * * @param {Object} options - Configuration options for setting up the environment. * @param {string} [options.file] - The specific environment file to load. If not provided, the function will attempt to load from a list of accepted files. * @param {BufferEncoding} [options.encoding="utf8"] - The encoding used to read the file. Default is "utf8". * @param {Object | ObjectValidator } [options.validators] - A list of validator object key-value to apply to the environment variables once loaded. Optional. * * @returns {void} This function does not return anything. */ declare function setup(options?: SetupOptions): Record<string, string>; export { setup, Validator };