0.0.0 • Published 3 years ago
@ionaru/node-utils v0.0.0
@ionaru/node-utils
Description
This package contains common Node.js utilities I use in my projects.
Usage
npm install @ionaru/node-utilsgetEnvironmentVariable(key: string, defaultValue?: string): string
Returns the value of the environment variable key or defaultValue if the environment variable is not set.
If defaultValue is undefined, the function will throw an error if the environment variable is not set.
import { getEnvironmentVariable } from '@ionaru/node-utils';
const envVar = getEnvironmentVariable('MY_ENV_VAR');
const envVarError = getEnvironmentVariable('MY_ENV_VAR'); // Errors with ""
const envVarWithDefault = getEnvironmentVariable('MY_ENV_VAR', 'default_value');