New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

node-getenv

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-getenv

Get and parse environment variables more easily.

latest
Source
npmnpm
Version
2.0.0
Version published
Maintainers
1
Created
Source

Get and parse environment variables more easily.

npm i node-getenv --save
const env = require('node-getenv')

// PORT=8080 node index.js
const port = env.getNum('PORT')  // 8080 (number)


// CONSUMER_ON=on node index.js
env.getBool('CONSUMER_ON')  // true

// node index.js
env.getNum('CONCURRENCY', 4)  // 4 (default value)

// node index.js
env.requireNum('CONCURRENCY')   // throw error
env.requireNumOrExit('CONCURRENCY')   // log error, then process exit

getNum(key, defaults)

Get environment variate in number type.

If the environment variate is undefined or not a valid number, return the default value.

getStr(key, defaults)

Get environment variate in string type.

If the environment variate is undefined, return the default value.

getBool(key, defaults)

Get environment variate in boolean type, supported values without case sensitive:

  • Truly: true, yes, on, open, t, y, 1.

  • Falsely: false, no, off, close, f, n, 0.

If the environment variate is undefined or unsupported, return the default value.

bindEnv(defaultValues)

Bind environment variates with default values, then returns them. It has no effect on real environmental variables (in process.env).

License: MIT

Keywords

getenv

FAQs

Package last updated on 09 Jan 2021

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