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

@brocan/env

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@brocan/env

A simple wrapper around node-config which provides a way to ensure the presence of required properties.

  • 1.2.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

[DEPRECATED] env

Instead of using env, the usage of convict is recommended!

A simple wrapper around node-config which provides a way to ensure the presence of required properties.

Usage

// will throw if PORT is not set
const env = require('@brocan/env').ensure([
    'PORT'
]);

const [ port, host ] = env.getAll([ 'PORT', 'HOST' ]);

// will return localhost if HOST is unset
const host = env.getOrDefault('HOST', 'localhost');

API

ensure(properties: Array<string>): env

Checks if the specified properties are set. Throws if any of the required properties is missing. The thrown Error object has a missing field with the array of the missing properties.

Returns the env instance if all properties are set.

get(property: string): string

Provides the same functionality as config.get().

getAll(...properties: string): Array<string>

Returns property values for multiple properties.

getOrDefault(property: string, value: any): any

If the specified property is set, then returns its value, otherwise returns the value passed as the second parameter.

getOrProvide(property: string, provider: (string) => any): any

If the specified property is set, then returns its value, otherwise calls the provider function with the property and returns the result.

has(property: string): boolean

Provides the same functionality as config.has().

FAQs

Package last updated on 11 Nov 2017

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