ts-env-get
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

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);

Package Sidebar

Install

npm i ts-env-get

Weekly Downloads

1

Version

1.0.3

License

MIT

Unpacked Size

8.48 kB

Total Files

8

Last publish

Collaborators

  • hscasn