env-getter
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

The Problem

repeatedly writing process.env is a very inefficient way to fetch more than one environment variable if want to default the environment variable is dev mode but not in production, use this library to assign conditional default values


usage

  1. input : pass object into first parameter return whole customized process.env object
import env from 'env-getter'

const { PORT, DB_NAME } = env({
  envsForDefault: ['dev','qa'],
  defaultValues: {
    PORT: 8080,
    DB_NAME: 'yourDB'
  }
})

// if PORT or DB_NAME is undefined, PORT and DB_NAME will be set to default when process.env equal to dev or qa
  1. input : pass key into first parameter return : process.env[key], or default value if it's undefined
const port = env('PORT', 8080) 

Readme

Keywords

Package Sidebar

Install

npm i env-getter

Weekly Downloads

6

Version

0.1.1

License

MIT

Unpacked Size

24.6 kB

Total Files

21

Last publish

Collaborators

  • jadson666