Socket
Book a DemoInstallSign in
Socket

envstrict

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

envstrict

schema like definitions for environment variables, throws an exception when missing required variables. Has a few helper methods exposed for filtering, merging an objects keys, and a few other things.'

Source
npmnpm
Version
1.1.2
Version published
Weekly downloads
6
200%
Maintainers
1
Weekly downloads
 
Created
Source

envstrict

schema like definitions for environment variables, throws an exception when missing required variables. Has a few helper methods exposed for filtering, merging an objects keys, and a few other things.

Usage

const envstrict = require('envstrict');
const envs = envstrict([{
  key: 'NODE_ENV',
  required: false,
  default: 'development',
  transformer: (val) => val.toUpperCase(),
  rename: 'environment'
}, {
  key: 'PORT',
  required: true
}, {
  key: 'FILE_PATHS',
  delim: /,\s?/,
  default: '~/app/dir1,~/app/dir2,~/app/dir3'
}]);

Tests

runs through basic tests for EnvStrict
  ✓ should have transformed the key for NODE_ENV to environment
  ✓ should be able to transform environment value to "DEVELOPMENT"
  ✓ should be able to delimit FILE_PATHS to an array
  ✓ should throw an error when a required key is not found

4 passing (23ms)

Keywords

envvars

FAQs

Package last updated on 09 Aug 2016

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