It throws exception if required env variables are missing.
Install it using npm
:
npm i @diegoti/simple-validation-for-env-variables
Import simple-validation-for-env-variables in your node app. Call check() function passing an array of ENV variables. If a variable is missing, the package will prevent the application from starting.
var express = require('express');
var path = require('path');
var cookieParser = require('cookie-parser');
const simpleValidationForEnvVariables = require('@diegoti/simple-validation-for-env-variables');
simpleValidationForEnvVariables.check(["MONGO_URL", "USER"]);
Output example.
Error:
Missing env[MONGO_URL] variable.