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

konfigure

v0.3.0

Published

Support for multiple configuration files with overrides from environment variables, good for deployment to PAAS

Downloads

17

Readme

##Konfigure

I like to deploy to PAAS providers like heroku and like an easy way to support getting configuration variables from the application environment.

Konfigure accepts the full path to a configuration file, the process environment variables, and an optional set of mappings between environment variables and configuration keys.

var config = require( 'konfigure').config(path.join( __dirname, "config.js" ), process.env
, [["EVD_ENV", "environment"],["EVD_FIXTURES", "directories.fixtures"],
    ["REDISCLOUD_URL", "redis.production" ], ["MONGOHQ_URL", "mongo.production.uri" ]])

If a file with the name of the configuration file with '.local.' interposed is found in the same directory, variables will be preferentially mapped from that. In the above this would be 'config.local.js' Developers can use this to override any shared settings for a local environment. Normally this file is added to .gitignore.

You can also map environment variables to various configuration keys. For example, in the above example, the MONGOHQ_URL is mapped to a configuration key called 'mongo.production.uri'.

As of version .2 you environment specific configurations out of the config file using a short-hand notation. Instead of doing this:

config.redis[ config.environment ]

You can just do this:

config.get(config.redis);

It will correctly parse the key for a configuration file that has a top level environment key like so:

var cfg = {
  PORT : 3000
, environment : 'development'
, mongo : {
		development : {
			           uri : 'mongodb://evd_local:27017/evd'
			, errorOptions : {
				dumpExceptions : true
				,    showStack : true
			}
		},

        test : {
            uri : 'mongodb://evd_local:27017/test'
            , errorOptions : {
                dumpExceptions : true
                ,    showStack : true
            }
        }

		, production : {
			uri : 'mongodb://jambo:foo'
		}
	}
}

You can also call a set function to set a value for the current environment in the same way:

config.set("mongo", {	uri : 'mongodb://jambo:baz'});

Allowing for an easy override of any value. You'll get a TypeError if the key doesn't exist. You can nest the the specification using .notation in string form as well:

config.set("db.mongo", {	uri : 'mongodb://jambo:baz'});

The code is well tested, and is dependent on lodash.