pg-transactional-outbox
Version:
A PostgreSQL based transactional outbox and inbox pattern implementation to support exactly once message processing (with at least once message delivery).
65 lines • 3.3 kB
TypeScript
/** The node.js environment variable interface */
export interface Env {
[key: string]: string | undefined;
}
/**
* Get a string from the environment variable.
* @throws Error if the variable is not found or empty and no default value was provided.
*/
export declare const getEnvVariableString: (env: Env, field: string, fallbackField: string, defaultValue?: string) => string;
/**
* Get a string from the environment variable.
* @throws Error if the variable is not found or empty and no default value was provided.
*/
export declare const getEnvVariableNumber: (env: Env, field: string, fallbackField: string, defaultValue?: number) => number;
/**
* Get a boolean from the environment variable. The true/1 value return true, false/0 return false. Everything else throws an error.
* @throws Error if the variable is not found or empty and no default value was provided.
*/
export declare const getEnvVariableBoolean: (env: Env, field: string, fallbackField: string, defaultValue?: boolean) => boolean;
/**
* Transforms a constant formatted value to snake case formatted one
* @param constantStr The CONSTANT_VALUE to convert to constantValue
* @returns the formatted value
*/
export declare const constantToCamel: (constantStr: string) => string;
export interface StringSetting {
constantName: string;
default: string;
func: typeof getEnvVariableString;
skipFallback?: boolean;
description: string;
}
export interface NumberSetting {
constantName: string;
default: number;
func: typeof getEnvVariableNumber;
skipFallback?: boolean;
description: string;
}
export interface BooleanSetting {
constantName: string;
default: boolean;
func: typeof getEnvVariableBoolean;
skipFallback?: boolean;
description: string;
}
/**
* Loads the configuration settings from the ENV variables into the settings object.
* @param map A mapping of all the env variables to config settings.
* @param envPrefix The prefix for the env variables to check first (e.g. "TRX_OUTBOX_" or "TRX_INBOX_").
* @param envPrefixFallback The fallback prefix if the other is not found. Useful for defining settings that should be used for both outbox and inbox.
* @param env The process.env variable or a custom object
* @returns The parsed configuration object.
*/
export declare const getConfigSettings: (map: (StringSetting | NumberSetting | BooleanSetting)[], envPrefix: string, envPrefixFallback: string, env?: Env) => Record<string, string | number | boolean>;
/**
* Shows the available env variables and their default values.
* @param map A mapping of all the env variables to config settings.
* @param envPrefix The prefix for the env variables to check first (e.g. "TRX_OUTBOX_" or "TRX_INBOX_").
* @param envPrefixFallback The fallback prefix if the other is not found. Useful for defining settings that should be used for both outbox and inbox.
* @param defaultOverrides Default values for the overrides.
* @returns A string with all the ENV config keys and their default values.
*/
export declare const getConfigSettingsEnvTemplate: (map: (StringSetting | NumberSetting | BooleanSetting)[], envPrefix: string, envPrefixFallback: string, defaultOverrides?: Record<string, string>) => string;
//# sourceMappingURL=env-settings.d.ts.map