Socket
Socket
Sign inDemoInstall

assert-process-env

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

assert-process-env

Load process.env variables and assert they exist.


Version published
Weekly downloads
2.5K
decreased by-50.95%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

assert-process-env

Simple module that loads env variables from process.env and asserts they exist. Reduces boilerplate if you are loading lots of envs and performing assertions.

Install

npm install --save assert-process-env

Usage

const assertProcessEnv = require('assert-process-env');

// Load an env and perform and assertion to ensure it exists
const ENV1 = assertProcessEnv('ENV1');

// Add a custom validator
const ENV2 = assertProcessEnv('ENV2', val => ['one', 'two'].includes(val));

// Display a custom message
const ENV3 = assertProcessEnv('ENV3', 'We forgot ENV3... Cmon...');

assertProcessEnv(key[, validator][, message])

  • key: Required. The name of your variable. Will be loaded as process.env[key]
  • validator: Optional. Function to perform additional validation. Assertion will throw if a falsy value is returned.
  • message: Optional. Message to display in the assertion. A default message will be used if nothing is provided.

License

MIT

FAQs

Last updated on 23 Nov 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc