1.0.3 • Published 6 years ago

ts-env-get v1.0.3

Weekly downloads
2
License
MIT
Repository
-
Last release
6 years ago

ts-env-get

Yet another TypeScript library for reading environment variables

npm install --save ts-env-get

Usage

// Will look for MY_VAR (always upper case)
// Throws if variable is empty
Env.get('my_var');

// Will look for MY_VAR
// Does not throw
Env.get('my_var', true);

// Will look for MY_VAR and return true if it is set to 'true' (lower or upper case)
// Throws if variable is empty
Env.isTrue('my_var');

// Will look for MY_VAR and return true if it is set to 'true' (lower or upper case)
// Does not throw
Env.isTrue('my_var', true);


// Returns Env.Mode.production if 'NODE_ENV' is set to 'production',
// returns Env.Mode.test if 'NODE_ENV' is set to 'test',
// returns Env.Mode.development otherwise
// Throws if 'NODE_ENV' is empty
Env.mode();


// Returns Env.Mode.production if 'NODE_ENV' is set to 'production',
// returns Env.Mode.test if 'NODE_ENV' is set to 'test',
// returns Env.Mode.development otherwise
// Does not throw
Env.mode(true);