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

envyconf

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

envyconf

Environment variable zero-config configuration in Node.js and Browser

  • 0.0.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

envyconf

Environment variable zero-config configuration in Node.js and Browser

Motivation

Configuration is tedious. Worrying about file locations, data formats and reacting to change is complex in Node. It gets even harder when developing code shared between Node and Browser.

envyconf is a simplistic approach:

  • Use only environment variables for configuration. Browser-side, use window, in Node use process.env.
  • To avoid naming conflicts, use a unique prefix for variable names. Export a
  • single method that can optionally pass defaults to be set unless already specified.
  • Receive all key-value pairs with the unique prefix, sans the prefix.

Example

In the browser, envyConf is available in window after loading the script. In Node.JS/Webpack, it can be loaded as a CommonJS or es6 module.

const {envyConf} = require('envyconf')
// or
import {envyConf} from 'envyconf'

Running this in Node.JS:

MYAPP_BAR='metasyntax' node -e "console.log(envyConf('MYAPP', {FOO: '42'}))"
# {FOO: 42, BAR: 'metasyntax'}

The same in Browser:

window.MYAPP_BAR='metasyntax'
console.log(envyConf('MYAPP', {FOO: '42'}))
// {FOO: 42, BAR: 'metasyntax'}

FAQs

Package last updated on 17 Dec 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