1.1.2 • Published 1 year ago
@ostai/env v1.1.2
ostai-env
Manage and get process.env
Install
$ npm i @ostai/envUsage
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
stringenvironment key - converter?
Converter | Array<Converter> | nullthe method to convert env value - defaults?
anythe default value if environment key is not found
const port = env('SERVER_PORT', env.integer, 80)Converter functions
env.booleanwhich treats'true'/'1'/Y/ etc astrueenv.integerconverts the given value to an integer.env.requiredif the env variable is not found, anRangeErrorwill throw
License
MIT