Read environment variables.
Install @enzsft/environment
:
pnpm add -E @enzsft/environment
To read an optional environment variable, this will return undefined
if the variable is not set:
import { readEnvironmentVariable } from '@enzsft/environment";
const value = readEnvironmentVariable('MY_ENVIRONMENT_VARIABLE');
To read a required environment variable, this will throw an error if the variable is not set:
import { readEnvironmentVariable } from '@enzsft/environment";
const value = readEnvironmentVariable('MY_ENVIRONMENT_VARIABLE', { required: true });