UNPKG

express-service-bootstrap

Version:

This is a convenience package for starting a express API with security, health checks, process exits etc.

54 lines (53 loc) 2.58 kB
/** * EnvironmentVariables class is a wrapper around NodeJS.ProcessEnv to provide type-safe access to environment variables. */ export declare class EnvironmentVariables { private readonly env; /** * Creates a new instance of EnvironmentVariables. * @param env The NodeJS.ProcessEnv object. * @returns A new instance of EnvironmentVariables. */ constructor(env?: NodeJS.ProcessEnv); /** * Gets the value of the environment variable. * @param key The key of the environment variable. * @returns The value of the environment variable or undefined. */ getString(key: string): string | undefined; /** * Gets the value of the environment variable or the default value if the environment variable is not set. * @param key The key of the environment variable. * @param defaultValue The default value to return if the environment variable is not set. * @returns The value of the environment variable or the default value. */ getStringOrDefault(key: string, defaultValue: string): string; /** * Gets the value of the environment variable as a number. * @param key The key of the environment variable. * @param defaultValue The default value to return if the environment variable is not set. * @returns The value of the environment variable as a number or the default value. */ getNumber(key: string, defaultValue: number): number; /** * Gets the value of the environment variable as a boolean. * @param key The key of the environment variable. * @param defaultValue The default value to return if the environment variable is not set. * @returns The value of the environment variable as a boolean or the default value. */ getBoolean(key: string, defaultValue: boolean): boolean; /** * Gets the value of the environment variable as an array. * @param key The key of the environment variable. * @param defaultValue The default value to return if the environment variable is not set. * @returns The value of the environment variable as an array or the default value. */ getArray<T>(key: string, defaultValue: Array<T>): Array<T>; /** * Gets the value of the environment variable as an object. * @param key The key of the environment variable. * @param defaultValue The default value to return if the environment variable is not set. * @returns The value of the environment variable as an object or the default value. */ getObject<T>(key: string, defaultValue: T): T; }