container.ts
Version:
Modular application framework
30 lines (29 loc) • 1.11 kB
TypeScript
import { ErrorChain } from "../lib/error";
/** Environment variables object. */
export interface IEnvironmentVariables {
[key: string]: string | undefined;
}
/** Environment error codes. */
export declare enum EEnvironmentError {
Get = "EnvironmentError.Get"
}
/** Environment error class. */
export declare class EnvironmentError extends ErrorChain {
constructor(code: EEnvironmentError, cause?: Error, context?: object);
}
/** Environment variables class. */
export declare class Environment {
readonly variables: IEnvironmentVariables;
constructor(...variables: IEnvironmentVariables[]);
/** Returns a copy of environment. */
copy(...variables: IEnvironmentVariables[]): Environment;
/** Returns true if environment variable key is set. */
has(key: string): boolean;
/**
* Get an environment variable value, or default value.
* Throws EnvironmentError if value is undefined and no default value provided.
*/
get(key: string, orDefault?: string): string;
/** Set an environment variable value. */
set(key: string, value: string): Environment;
}