🚀 Socket Launch Week 🚀 Day 5: Introducing Socket Fix.Learn More
Socket
Sign inDemoInstall
Socket

nfs-config-resolver

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nfs-config-resolver

1.2.0
Source
npm
Version published
Weekly downloads
35
-23.91%
Maintainers
1
Weekly downloads
 
Created
Source

config-resolver

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
};

prefix key with @ to allow a parameter to be overriden with environment parameter

// development.js

module.exports = {
  "port":81,
  "mongodb":{
    "@host:MONGO_HOST": "localhost"
    "@port:MONGO_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

FAQs

Package last updated on 24 Nov 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts