Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

env-validator

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

env-validator

Validates node version and environment variables required for app

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

env-validator

Ensure that your Node app is running in a valid environment.

Call the validator to check that:

  • You're on the right Node version at runtime
  • All the required environment variables have been set

In an effort to fail fast, we check these two important features up front.

Install

npm install env-validator --save

Usage

Put the following function call close to the beginning of your program:

import validate from 'env-validator'

const env = {
  nodeVersion: '0.12.x'
  varNames: [
    'GITHUB_OAUTH_CLIENT_ID',
    'GITHUB_OAUTH_CLIENT_SECRET'
  ]
}
validate(env)

// the rest of your app below

Environment Config

Put the following properties in your env config object:

nodeVersion - (String) - Give a full major.minor.patch version of Node.js. Where you want to be variable, use an x, as in 0.13.x. Will throw an error if the Node version is not at least as high as what is expected. Compares with process.version.

varNames - (Array) - The names of environment variables that must be set in order for your app to work. Will throw an error indicating all the missing variables if they're not available from process.env.

Keywords

FAQs

Package last updated on 17 Aug 2015

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc