@ostai/env

1.1.1 • Public • Published

Build Status Coverage

ostai-env

Manage and get process.env

Install

$ npm i @ostai/env

Usage

type Converter = (
  value: any,
  // The key of the env variable
  key: string,
  // If the env key does not exist, then `is_default` is true
  is_default: boolean
) => any

env(key: string, converter?: Converter | Array<Converter> | null, defaults?: any): any
  • key string environment key
  • converter? Converter | Array<Converter> | null the method to convert env value
  • defaults? any the default value if environment key is not found
const port = env('SERVER_PORT', env.integer, 80)

Converter functions

  • env.boolean which treats 'true' / '1' / Y / etc as true
  • env.integer converts the given value to an integer.
  • env.required if the env variable is not found, an RangeError will throw

License

MIT

Package Sidebar

Install

npm i @ostai/env

Weekly Downloads

1

Version

1.1.1

License

MIT

Unpacked Size

3.42 kB

Total Files

3

Last publish

Collaborators

  • kael