nor-config

0.1.1 • Public • Published

Build Status

nor-config -- Config library for Node.js

Warning! This code is experimental and in a state of preliminary development. Use at your own risk.

License

It's under MIT-style open source license -- see https://github.com/Sendanor/nor-config/blob/master/LICENSE.txt.

Installation

You can install it simply from NPM:

npm install nor-config

Usage

App defaults can be configured in file ./config.json (or later in the source code with ._def()):

{
  "port": 8080
}

Local settings (overrides values in ./config.js) for the app can be set in ./local/config.json:

{
  "host": '192.168.1.1',
  "port": 3000
}

The ./app.js uses it like this:

var config = require('nor-config').from(__dirname);
config._def('host', 'localhost');   // Set default value
config._require('port');            // If port is missing, throws an exception.
console.log(config.host + ':' + config.port);

The output will be 192.168.1.1:3000.

The library will also read package.json if it exists, and saves contents from it to config.pkg.

Readme

Keywords

none

Package Sidebar

Install

npm i nor-config

Weekly Downloads

0

Version

0.1.1

License

MIT

Last publish

Collaborators

  • jhh