@mdf.js/utils
Version:
MMS - API Core - Common utils tools
39 lines • 1.89 kB
TypeScript
/**
* Copyright 2024 Mytra Control S.L. All rights reserved.
*
* Use of this source code is governed by an MIT-style license that can be found in the LICENSE file
* or at https://opensource.org/licenses/MIT.
*/
import { ReadEnvOptions } from './types';
/**
* Read environment variables (`process.env`) and return an object with the values sanitized and the
* keys formatted
* @returns
*/
export declare function formatEnv<T extends Record<string, any> = Record<string, any>>(): T;
/**
* Read environment variables (`process.env`), filter them based in the indicated prefix, and return
* an object with the values sanitized and the keys formatted
* @param prefix - prefix to filter
* @returns
*/
export declare function formatEnv<T extends Record<string, any> = Record<string, any>>(prefix: string): T;
/**
* Read environment variables (`process.env`), filter them based in the indicated prefix, and return
* an object with the values sanitized and the keys formatted based on the specified options
* @param prefix - prefix to filter
* @param options - options to be used for key/value parsing and sanitize
* @returns
*/
export declare function formatEnv<T extends Record<string, any> = Record<string, any>>(prefix: string, options: Partial<ReadEnvOptions>): T;
/**
* Process a source, encoded as a environment variables file, filter them based in the indicated
* prefix, and return an object with the values sanitized and the keys formatted based on the
* specified options
* @param prefix - prefix to filter
* @param options - options to be used for key/value parsing and sanitize
* @param source - source to be processed
* @returns
*/
export declare function formatEnv<T extends Record<string, any> = Record<string, any>>(prefix: string, options: Partial<ReadEnvOptions>, source: Record<string, string | undefined>): T;
//# sourceMappingURL=formatEnv.d.ts.map