1.1.1 • Published 7 years ago

@wandersonwhcr/config v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
7 years ago

config

A Simple Configuration Loader for Node.js

Travis npm license

Usage

This package can be used to load configurations asynchronously using Promises.

// Dependencies
const Config = require("@wandersonwhcr/config").Config;

// config/default.d/00-default.json   -> { "foo": "bar" }
// config/default.d/10-something.json -> { "baz": "qux" }
// config/local.d/99-local.json       -> { "foo": "one", "somebody": "someone" }

// Construction
var config = new Config([
    "config/default.d/*.json",
    "config/local.d/*.json"
]);

// Fetch Files
config.fetch().then(function (config) {
    // { "foo": "one", "baz": "qux", "somebody": "someone" }
}).catch(function (error) {
    // Whoops!
});

Synchronous configuration loading can be used directly, but it's not recommended.

// Fetch Files (Sync)
var result = config.fetchSync();
// { "foo": "one", "baz": "qux", "somebody": "someone" }

Reason

I created this package because I didn't find any other package that loads files by glob and merges them alphabetically by filename. This package is very inspired by Zend Framework's configuration loading and a lot of Linux packages that load configuration from directories (aka conf.d directories).

License

This project is licensed under MIT License. See LICENSE file for details.

1.1.1

7 years ago

1.1.0

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.1.0

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago