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

keef

v5.0.0

Published

Multi tier configuration loader as a package

Downloads

17

Readme

keef

Codeship Status for megadoomer/keef

Multi tier configuration loader as a package

The conf package reads configurations options in an overriding fashion from a number of sources. In order of importance:

  1. System level overrides
  2. Command line arguments
  3. Environment variables
  4. A configuration file(s)
  5. Data loaded from an ETCD2 backend if specified
  6. System specified defaults

Overrides

Overrides can not be overriden or changed at any point in time. The are defined in conf/lib/overrides.js and should be reserved for static run time properties. Conf serves as a central place to get that information.

For example, the full path to the packages directory is resolved at run time and loaded in to the conf loader. It won't / can't change during run time, but may change in the future. By getting the information from conf, application logic does not need to change between restarts or releases.

If overrides need to be change or added the overrides.js file must be changed

Command Line Arguments

Command line arguments are the highest level of maliable values. The can be used to set specific and nested values in the configuration JSON document but using a : spearator between keys. For example, using the flag: --foo:bar=1, would create an object like

{
	"foo":{
		"bar": 1
	}
}

Environment Variables

Environment variables work much the same as command line arguments. However, most bash implenetations don't read :'s very well, so the double underscore ( __ ) is used in its place foo__bar=1 npm start

{
	"foo":{
		"bar": 1
	}
}

Conf File

The conf options can be set to read specific configuration from a file(s). The value should be a full path. If the path points to a directory, the conf loader will read all json files, sort them and load their values in an overriding order. Sorting is done in a descending, lexigraphical order.

└── conf
    ├── 20-second.json
    ├── 10-first.json
    └── 30-third.json

Given the above directory of conf files, the server can be configured by pointing the conf arguments at the directory

node server --conf=$HOME/conf

The configruation would be read in the following priority 10-first.json < 20-second.json < 30-third.json

where 20 overrides 10, and 30 overrides 20.

System defaults

defaults are what they sound like. Sane defaults for values that are needed to get the application running. They are located in conf/lib/defaults.js and are used only as fallback values.

Option Shorthands

Top level options can be aliased. Short hand aliases can be found and defined in the lib/shorthands.js module.

Flag | Shorthand | Description -----|:---------:|------------ PORT | p | Specifies the port the server will bind to logger | l | specify the type(s) of logging transports for the server to use

the following invocations are treated the same

node server --PORT=3001 --logger=stdout --logger=file
PORT=3001 logger=stdout nodeserver -l file
node server -p 3001 -l stdout -l file