@mx7/tenv
Version:
type-safe environment variable parser
32 lines (30 loc) • 1.08 kB
TypeScript
/**
* @class Env
* @description This class is used to determine the environment variables
* @param {Record<string, string>} envObj - The environment object from process.env
*/
declare class Env<T = unknown> {
private value;
private parsed;
constructor(envObj?: Record<string, string>);
get isProduction(): boolean;
get isDevelopment(): boolean;
get isStaging(): boolean;
get isTest(): boolean;
get(this: Env): T;
key<K = string>(key: keyof typeof Env.prototype.value, factor: true): Env<K>;
key<K = string>(key: keyof typeof Env.prototype.value, factor?: false): Env<K | undefined>;
key<K = string>(key: keyof typeof Env.prototype.value, factor: K): Env<K>;
private checkBoolean;
bool(this: Env): Env<boolean>;
email(this: Env): Env<string>;
url(this: Env, options?: {
ipv6?: boolean;
}): Env<string>;
private checkNumber;
integer(this: Env): Env<number>;
float(this: Env): Env<number>;
unsigned(this: Env): Env<number>;
signed(this: Env): Env<number>;
}
export { Env as default };