📅 You're Invited: Meet the Socket team at RSAC (April 28 – May 1).RSVP
Socket
Sign inDemoInstall
Socket

ez-config

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ez-config

A simple environment-aware configuration utility exporting clean JS objects

0.2.1
latest
npm
Version published
Weekly downloads
14
27.27%
Maintainers
1
Weekly downloads
 
Created
Source

EZ Config

A simple configuration file loader for node.js following some of the basic style of node-config, but with a focus on simplicity. It supports js, json, and yaml configuration files, as well as environmental overrides.

npm release

Installation

$ npm install ez-config --save

Basic usage

Create a config directory at the root of your app and place a default.json with the following contents:

{
  "demo": {
    "rad": "cool"
  }
}

Then do this:

var config = require("ez-config");
config.get();
// { "demo": { "rad": "cool" } }
config.get("demo.rad");
// "cool"
config.get("nothing.real");
// undefined (not a thrown error)

Notice that get accepts hoek.reach-style paths, and will return undefined if they do not exist.

Advanced use

  • Obeys the import hierarchy described here.
  • Allows setting the NODE_CONFIG_DIR environment variable to something other than config.
  • Allows an environmental override via JSON string, e.g. NODE_CONFIG='{"demo":"foo"}' node app.js
  • Allows a command-line override via JSON string, e.g. node app.js --NODE_CONFIG='{"demo":"foo"}'
  • You can include the ES6 code if that's useful, with require("ez-config/es6") -- the Object.assign polyfill will not be loaded

Tests

I'm checking basic functionality, but coverage is currently disabled due to ES6 limitations in Lab.

Keywords

es6

FAQs

Package last updated on 27 Jan 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