JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1817
  • Score
    100M100P100Q106909F
  • License MIT

A nice little helper for retrieving configuration from env. vars

Package Exports

  • common-env

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (common-env) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

common-env

Build Status Deps Version

A little helper I use everywhere for configuration. Environment variables are a really great way to quickly change a program behavior.

npm

npm install common-env

Usage

var logger = console;
var env = require('common-env')(logger);

// AMQP_LOGIN="plop" AMQP_CONNECT=true node test.js
var config = env.getOrElseAll({
  amqp: {
    login: 'guest',
    password: 'guest',
    host: 'localhost',
    port: 5672,
    connect: false
  },

  FULL_UPPER_CASE: {
    PORT: 8080
  },

  MICROSTATS: {
    HASHKEY: 'B:mx:global'
  }
});

t.strictEqual(config.amqp.login, 'plop'); // converted from env
t.strictEqual(config.amqp.port, 5672);
t.strictEqual(config.amqp.connect, true); // converted from env
t.strictEqual(config.FULL_UPPER_CASE.PORT, 8080);

Changelog

v1.1.0

feat(options): allow user to ask common-env to not display env vars. values, closes #1 asked by @keruspe