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 🙏

© 2025 – Pkg Stats / Ryan Hefner

confd

v2.1.0

Published

Multi-files JSON configuration loader

Downloads

13

Readme

NPM version Dependency Status

conf.d

Multi-files JSON loader

Conf.d serves JSON documents obtained from static files and arbitrary paths passed by the user.
According to the paths being passed and the way the files are organized in folders (and sub-folders), JSON docs are mixed together and bundled into one.

Conf.d is to be used when there is a need for serving complex JSON documents, composed of default keys/values that can be overridden depending on arbitrary, runtime-picked criteria and loaded from a tree of files that reflects those possible override schemata.

Files and folders organization stays fixed, but JSON documents produced by conf.d are dynamically generated starting from those files and the rules passed to conf.d.

Documents are unified by using the unionj module.

Warning

Documentation still isn't complete

Install

$ npm install -g confd

Example Usage

First of all prepare your JSON configuration file(s) (you need root rights to execute these):

mkdir -p /etc/conf.d/myinstancename
touch /etc/conf.d/myinstancename/conf.json
echo "{\"key\":\"value\"}" > /etc/conf.d/myinstancename/conf.json

Finally you can either use the command-line utility to read your JSON conf:

confd cli get /etc/conf.d myinstancename

# {"key":"value"}

Or you can expose them as a RESTful webservice:

confd rest --port 8080 --from /etc/conf.d

curl --get localhost:8080/confd/myinstancename

# {"key":"value"}

Or you can embed conf.d straight into your Node.js code:

var confd = require('confd');
var conf  = confd.from('/etc/conf.d');

conf.get('myinstancename')
.then(function(obj)
{
    console.log('Result is: "%s"', JSON.stringify(obj));
    // Result is: "{"key":"value"}"
})
.catch(function(err)
{
    // Handle errors here...
});

When used as a node module the value retrieved is an actual Javascript object instead of a string containing a JSON doc.

Paths

Let's say we have the following files and folders structure:

/etc/conf.d/
    /subfolder1/
        file1.json => {"k": "v1"}
        file2.json => {"k": "v2"}
        /subfolder2/
            file1.json => {"x": "y"}
            file2.json => {"x": "y"}

If we execute confd cli get /etc/conf.d subfolder1 we obtain {"k": "v2"} as a result.
Here's what confd did to satisfy our request:

  • We told confd to get the files from root folder /etc/conf.d/, subfolder 'subfolder1'
  • confd then proceded to merge the contents of that folder, hence file1.json and file2.json
  • The result is the merge of the two JSON documents (for the merge rules, see unionj project)

"Common" documents

[Coming soon]

Strategies

Conf.d offers two different strategies to load the configuration data:

  • Leaves
  • Backcursion

Leaves

When using the "Leaves" strategy all the documents from the same folder are bundled into one.
There will be no sub-/super-paths traversing: the documents that's going to be bundled are just the ones into the one folder addressed by the provided path.

Backcursion

[Coming soon]

Array

[Coming soon]

Next steps

  • MongoDB docs loading
  • New startegy: "Named Backcursion"
  • RethinkDB docs loading

License

MIT © Nicola Orritos