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

nfs-config-resolver

v2.0.4

Published

[![Build Status](https://travis-ci.org/nodeframe/config-resolver.svg?branch=master)](https://travis-ci.org/nodeframe/config-resolver) [![npm](https://img.shields.io/npm/v/nfs-config-resolver.svg)](https://www.npmjs.com/package/nfs-config-resolver)

Downloads

303

Readme

Build Status npm

config-resolver

An environment base config resolver that will reduce your worries about config and environments! Have a development environment and the production where you need it to be different config? fine! config-resolver will solve it! Have a config you want to declare only once and share on all environments? fine! config-resolver got you covered!

Installation

npm install nfs-config-resolver --save

Usage Example

Create configs folder within your project directory

Create common.js development.js production.js files inside configs directory

// common.js

module.exports = {
  "host":"localhost",
  "port":80
};
// development.js

module.exports = {
  "port":81,
  "mongodb":{
    "host": "localhost"
    "port": "27017"
  },
  "mode": "admin"
};
// production.js

module.exports = {
  "port":82
};

How to use

You can override configuration with environment parameter

// run with environment NODE_ENV=development MONGO_HOST=182.166.12.2 MODE=customer
const config = require('nfs-config-resolver')();

console.log(config)
/*
 {
  "port":81,
  "mongodb":{
    "host": "182.166.12.2"
    "port": "27017"
  },
  "mode": "customer"
}
*/
// run with environment NODE_ENV = production
const config = require('nfs-config-resolver')();

console.log(config.port)
// 82

ENV compatible

The great thing about this config-resolver is that it can help you on declaring config that needs to bind with the Environment Variables (eg. docker ENV)

You can declare you config by just adding @ prefix and comma like so:

// development.js

module.exports = {
  "port":81,
  "mongodb":{
    "@host:MONGODB_HOST": "localhost"
    "@port:MONGODB_PORT": "27017"
  },
  "@mode": "admin"
};

The config generated from this file will be as same as this config

// development.js

module.exports = {
  "port":81,
  "mongodb":{
    "host": process.env.MONGODB_HOST || "localhost"
    "port": process.env.MONGODB_PORT || "27017"
  },
  "mode": process.env.MODE || "admin"
};

by this config, at runtime, the config value will be overwritten by the environment variable, wether it's linux or Docker. This allow you to have a cleaner setting and save your time on worrying and declaring those environments.

as from the example above, you can override the mongo host just by changing the environment variable at runtime, like this

MONGODB_HOST=11.11.11.11 node ./index.js

and so on.

The most beneficial to this feature is those who make Docker image!