Socket
Book a DemoInstallSign in
Socket

@postnord/pretty-env

Package Overview
Dependencies
Maintainers
17
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@postnord/pretty-env

Easily handle env vars

0.0.8
latest
Source
npmnpm
Version published
Maintainers
17
Created
Source

Introduction

This module gives you a nice interface to handle environment variables.

Quick start

import envService from '@postnord/pretty-env'

// in batch
const { API_BASE_URL, NODE_URL } = envService.requireEnvs({ envs: ['API_BASE_URL', 'NODE_URL'] }) // returned envs are typed as string, so no more process.env.NODE_URL as string

// single env var fetch
const myEnv = envService.requireSingleEnv({ env: 'mySingleEnv' })

// When the env does not exist
envService.requireSingleEnv({ env: 'myNonExistingEnv' }) // throws "Environment variable myNonExistingEnv is missing"

// If you want to parse and validate the value
envService.requireSingleEnv<Array<string>>({
  env,
  parser: JSON.parse,
  validateValue: {
    validationFunction: Array.isArray,
    errorMessage: 'Should be an array but is not',
  }
})

FAQs

Package last updated on 25 Apr 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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.