Ensure environment variables are set at both runtime and compile-time. TypeScript users benefit from auto-completion of variables.
$ yarn add chickenv
If environment variables are not set, the method will throw.
import chick from 'chickenv'
// throws if missing
const env = chick.check(
process.env,
['FOO', 'BAR', 'BAZ']
)
env.FOO // guaranteed to be set
Alternative assertion method.
import chicken from 'chickenv'
chicken.assert(process.env, ['FOO', 'BAR', 'BAZ'])
process.env.FOO
If you need more advanced features, you should probably take a look at other libraries, such as runtypes.
Art is in the eye of the beholder
Pronounced chick-env (🐤env), or chicken-v (🐔v).
MIT © Vladimirs Nordholm