npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

envkonf

v1.0.7

Published

A node.js module that helps with loading of hierarchical configuration from environment variables as suggested by twelve factor methodology

Downloads

1

Readme

envkonf

Description

node-env-configuration is a node.js module that helps with loading configuration as suggested by twelve factor methodology www.12factor.net:

The twelve-factor app stores config in environment variables (often shortened to env vars or env). Env vars are easy to change between deploys without changing any code; unlike config files, there is little chance of them being checked into the code repo accidentally; and unlike custom config files, or other config mechanisms such as Java System Properties, they are a language- and OS-agnostic standard. … In a twelve-factor app, env vars are granular controls, each fully orthogonal to other env vars. They are never grouped together as “environments,” but instead are independently managed for each deploy. This is a model that scales up smoothly as the app naturally expands into more deploys over its lifetime.

Quick Start

Suppose you have this json default configuration for your node application:

var defaults = {
  http_port: 8000,
  https_port: 8001,
  mongodb: {
    name: 'api', // Database name
    host: '127.0.0.1', // Database host
    user: '', // Database user
    password: '', // Database password
    port: 27017,
    options: {} // MongoDB options
  }
}

Then you want to override this configuration (or subset of it) for your production environment. You define the next environment variables :

API_APP_HTTP_PORT='80';
API_APP_HTTPS_PORT='443';
API_APP_MONGODB_NAME='api_db';
API_APP_MONGODB_HOST='api.example.com';
API_APP_MONGODB_USER='username';
API_APP_MONGODB_PASSWORD='secret password';

In your code your can override defaultConfiguration object with these environment variables:

var envkonf = require('envkonf');
var config = envkonf({
  defaults: defaults,
  prefix: 'apiApp' // Read only env vars starting with API_APP prefix
});

Notes

  • Underscore character in environment variables (excluding prefix underscore) results in adding a new hierarchy level in result object:
API_APP_MONGODB_NAME = 'api_db'  # Matches obj.mongodb.name property
API_APP_MONGODB_URL_HOST = 'api.example.com'  # Matches obj.mongodb.url.host propery

Configuration parameters

Name | Default Value | Description ------|---------------|------------- prefix | '' | Pascal case prefix. Restrict variables to read from environment to those starting with this prefix in snake case arraySeparator | null | This character, if specified, is used as an array separator. So if a variable contains this character, the variable is parsed as an array of values defaults | {} | Default object values

Running Tests

$ npm test

Creds

Ezequiel Cuñado

License

MIT