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

pony-config

v4.0.1

Published

Small configuration loader

Downloads

305

Readme

pony-config

Build Status Coverage Status Known Vulnerabilities

Versatile, Predictable Configuration

config.get('best.configuration.library')

Configuration can be combined from many sources

  • JSON files
  • Command Line Arguments
  • Javascript Objects
  • Environment Variables
  • Programmatically

Configuration sources are merged predictably

  • Config properties are extended and replaced recursively
  • Powerful debug trace of each config value's source
  • Makes it easy to set defaults, load common configurations, and override with environment specific config.

Configuration is easily accessed through dot paths

Both get and set methods support dot paths, for example get('name.first')

Different Configuration for each Run-Time Environment

Configuration can be selected at run-time for each of your environments, for example Production, Stage, Dev, Dev-Josh, Dev-Scott.

The run-time environment is determined by searching file paths and environment variables.

config.findRuntimeEnvironment({
    paths:['./env-file'],
    env: 'ENVIRONMENT',
    default:'prod');

Sources can be applied in layers

var config = require('pony-config');

config
.file('common-config.json')                 // common for all environments
.when('test').file('local-config.json');    // test only configuration

See more examples here.

Getting Started

npm install --save pony-config

The config module is a singleton. Set up your configuration in your main file at startup, access it everywhere in your project.

var config = require('pony-config');

See the api documentation for the full pony-config API documentation.

Debugging

pony-conifg provides several tools to help you debug your configuration. See the debugging documentation for the debug API.

Secure Keys

Always store key files outside of your repo

In production, keys are often served to applications through environment variables, while locally keys live on the file system. To keep keys safe, store them outside your repo, for example, in ~/keys/ and use pony-config to load the appropriate key.

config
    .when('dev').file('~/keys/secret.key')
    .when('prod').env( 'secret', 'SECRET_API_KEY')

See Also

pony-config uses

  • minimist for command line argument parsing because it does exactly one thing and does it well.
  • fs-coalesce to search file paths. This module (also by ponycode) extends the file path syntax to include '~', and automatically matches on the first extant file in an array of paths.

Tests

npm test

For coverage, run npm run coverage


License

Copyright (c) 2014,2020 PonyCode Corporation Licensed under the MIT license.