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

json-config-ext

v1.0.3

Published

An extensible json configuration plugin for nodejs

Downloads

15

Readme

json-config-ext

Build Status NPM version Coverage Status

By Roman Lo

An extensible json configuration plugin for nodejs.

Installation

json-config-ext is available on NPM. You can install json-config-ext simply by enter the following command:

npm install --save json-config-ext

Usage

// load from file `${process.env.cwd()}/config/config.json`
var config = require('json-config-ext').config;

Advanced Topic

Environment Configuration

As default, json-config-ext will try to get the config/config.json under the process.cwd() directory. But you can set/modify the following environment parameters to tell this plugin to load the specific configurations.

process.env.NODE_ENV

The node environment stands for the suffix of the configuration file.

For example, when process.env.NODE_ENV is set to prod, plugin will try to load config.prod.json under the default configuration directory.

process.env.CONF_EXT_DIR

CONF_EXT_DIR indicates the configuration directory location. It supports both absolute path or relative path. Find out more in the following samples:

  1. Absolute path sample

    As:

    process.env.CONF_EXT_DIR = '/etc/yourapp/config';

    Then:

    // load from file `/etc/yourapp/config/config.json`
    require('json-config-ext').config;
  2. Relative path sample

    As:

    process.env.CONF_EXT_DIR = './myconfig';

    Then:

    // load from file `${process.env.cwd()}/myconfig/config.json`
    require('json-config-ext').config;

process.env.CONF_EXT_NAME

CONF_EXT_NAME indicates the configuration file name. By the default, the configuration file name is config, and the plugin will load config.${NODE_ENV}.json. By changing the CONF_EXT_NAME, you can load different configuration files. Here is an example:

// set the configuration file name to `myconf`
process.env.CONF_EXT_NAME = 'myconf';

// load from file `${process.env.cwd()}/config/myconf.json`
var config = require('json-config-ext').config;

Extensive JSON

Calling the Json extensively, this means Json can be extended/inherited between each others. This is also the main spotlight feature of this plugin.

Here, I introduce three reserved keywords within the root level of the json file:

  1. __name

    The __name keyword is use to declare the name of the json file/object, which can be use in the __extends array.

  2. __extends

    The __extends array tells the plugin to load and merge the specific json files in a preset order(order by the index ascendingly).

    You can put

  3. __excludes

    The __excludes array tells the plugin not to load the specific json files, through out the whole loading process.

    NOTICE: I didn't implements this feature yet.

No words could more straight than seeing the code to know how to extends your json files. Let go to the advanced-usage example and take a look at this awesome feature!

Contributions

Contributions are super welcome here! If you have any good idea about this project, please feel free to let me know.

You can contact me by this e-mail: [email protected]

Or just leave a message on the issue page :)