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

minconf

v0.3.1

Published

`minconf` is a minimal configuration library.

Downloads

5

Readme

minconf

minconf is a minimal configuration library.

minconf loads an application's configuration based on the value of an environment variable, e.g. NODE_ENV. minconf supports merging of environment variables and command line arguments.

Configuration

Define environment configurations as objects or in files.

var configs = {
  $: {

    // defines merge order of object properties, files, command-line arguments and the environment
    envs: {
      development: 'common config.local.json ARGV ENV',
      test: 'common test ARGV ENV',
      production: 'common production ARGV ENV'
    }
  },

  common: {
    database: {
      user: 'superuser'
      password: 'password'
    }
  },

  test: {
    database: {
      password: 'secret'
    }
  },

  production = require('./config-production.json')
};

Configure minconf. In this example, the environment is chosen based on the value of NODE_ENV environment variable. If NODE_ENV is not set, it defaults to 'development'.

var config = MinConf.load(configs).config;

When running in development

config.database.user == 'superuser'
config.database.password == 'password'

When running in NODE_ENV=test

config.database.user == 'superuser'
config.database.password == 'secret'

Merging Precendence

Merging occurs left to right. In this example,

development: 'common config.local.json ARGV ENV'

The base opbject is common, then overriden by a file config.local.json, then overridden by ARGV, which are the command line arguments and then overriden by ENV, which are the process environment variables. In other words, environment variables override command line arguments which override a local configuration file which overrides the base object.

WARNING: Avoid merging environment variables. Environment variables can be affected by parent process or other init scripts.

Overriding Selector

To override the environment variable seletor and default enviroment, set options.envSelector and options.defaultEnv respectively

var configs = {
    $: {
      options: {
        envSelector: 'NODE_ENV',
        defaultEnv: 'development',
        wd: process.cwd()
      },

      envs: {
        ...
      }
    }
}

Running your app

Use any combination of config files, environment variables and command line arguments.

NODE_ENV=test node app.js --db.password='secret'

Use env command to use periods in environment variables. It is recommended to use command line arguments instead.

env 'db.user=foo' 'db.pass=secret' node app.js

License

The MIT License

Copyright (c) 2014 Mario Gutierrez [email protected]

See the file LICENSE for copying permissions.