0.0.0 • Published 1 year ago

@ionaru/node-utils v0.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@ionaru/node-utils

npm version npm version Build Status codecov

Description

This package contains common Node.js utilities I use in my projects.

Usage

npm install @ionaru/node-utils

getEnvironmentVariable(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');