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

@studiohyperdrive/env

Package Overview
Dependencies
Maintainers
9
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@studiohyperdrive/env

Environment helper used at Studio Hyperdrive.

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11
decreased by-15.38%
Maintainers
9
Weekly downloads
 
Created
Source

Env

Environment utility for NodeJS.

Table of contents

  • Getting Started
  • Usage

Getting Started

Install the package

# NPM
npm install --save @studiohyperdrive/env

# Yarn
yarn add --save @studiohyperdrive/env

Usage

import Env from '@studiohyperdrive/env';

get

Fetches an environment variable as a string.

get(key: string, allowNull = false): string

Usage:

  const variable = Env.get('PARAM_NAME');
  const nullableVariable = Env.get('PARAM_NAME', true);
getAsBoolean

Casts the fetched environment variable to a boolean.

getAsBoolean(key: string): number

Usage:

  const variable = Env.getAsBoolean('PARAM_NAME');
getAsNumber

Casts the fetched environment variable to a number.

getAsNumber(key: string): number

Usage:

  const variable = Env.getAsNumber('PARAM_NAME');
getAsArray

Casts the fetched environment variable to an Array.

getAsArray(key: string, separator = ','): number

Usage:

  const variable = Env.getAsArray('PARAM_NAME', ';');
getAsObject

Casts the fetched environment variable to an object using JSON.parse.

getAsObject(key: string): number

Usage:

  const variable = Env.getAsObject('PARAM_NAME');
validateEnv

Validate process.env against a Joi Schema.

validateEnv(schema: Joi.Schema, options: Joi.ValidationOptions): ValidationResult

Usage:

  const validationResult = Env.validateEnv(schema, options);
validateEnvAsync

Validate process.env against a Joi Schema in an asynchronous fashion.

validateEnvAsync(schema: Joi.Schema, options: Joi.ValidationOptions): ValidationResult

Usage:

  const validationResult = await Env.validateEnvAsync(schema, options);

FAQs

Package last updated on 30 Jan 2020

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