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 🙏

© 2026 – Pkg Stats / Ryan Hefner

spig

v1.0.2

Published

SPIG is a simple and powerful configuration tool that simplifies the configuration of any NodeJS module.

Downloads

5

Readme

Build Status (develop) Coverage Status

SPIG

SPIG is a simple and powerful configuration tool that simplifies the configuration of any NodeJS module.

Why SPIG?

Most of the common configuration modules are overloaded with features and are very complex to set up.

SPIG is the simple and lightweight configuration solution for small and big projects.

Setting up SPIG

You just have to install SPIG to your module:

npm install spig --save

Using SPIG

SPIG is pretty easy to use, you just have to require the module:

var config = require('spig');

SPIG will directly return your configuration so that you do not have to type a lot of boilerplate code.


SPIG reads the file config.js or config.json (by using require()) from the directory where the application where started (retrieved by process.cwd()). This file must contain a valid JSON (if it is a JSON file) or must return a plain old JavaScript object in the style of a JSON.

The configuration file may include other configuration files by using the property $import in the root of the object (or JSON) which has to have a string or an array of strings as the value. These strings must point to other configuration files relative from the directory where the importing configuration file lives or absolute. As the imported files my import other files too, you must take care of not building dependency cycles as these will result in an error.

The imported files are merge with the importing configuration file, starting from the root and with a higher priority. That is imported configuration files will overwrite the properties set in the importing configuration file.


If any of the files (either the root configuration file or any of the the imported files) can not be found, an exception is thrown.

Customizing SPIG

SPIG can be customized using the follow command line options:

  • --spig-prop-import or -spi: This option must be followed by the property name that should replace the default property to import files ($import).
  • --spig-config or -sc: This option must be followed by the file name that should replace the default configuration file name (config).
  • --spig-no-throw or -snt: This option disables the exception throwing and errors are only logged to the console. If any of the imported configurations contain errors, they are not merged with the importing configuration. If the root configuration contains errors, an empty object is returned by the require(...) statement.

Examples

Database Connection

Setting up a database connection and storing all the required configuration can be really annoying as you have to grab data from everywhere. Using SPIG all this data is held at a single place, the configuration.

The following files represent a simple database connection setup using mongoose.

Main File (index.js)

var mongoose = require('mongoose');
var config = require('spig');

mongoose.connect(config.db.url, config.db.options);

Configuration File (config.json)

{
    "db": {
        "url": "mongodb://localhost/db",
        "options": {
            "user": "root",
            "pass": "12345678"
        }
    }
}

And thats it - you have extracted the database configuration from your code.


If you do not want to check in your credentials for the database, you can create a private configuration file and set it up like this:

Configuration File (config.json)

{
    "$import": "config-private.json",
    "db": {
        "url": "mongodb://localhost/db"
    }
}

Private Configuration File (config-private.json)

    "db": {
        "options": {
            "user": "root",
            "pass": "12345678"
        }
    }