@eddieajau/config-factory

A simple wrapper for nconf.

Usage no npm install needed!

<script type="module">
  import eddieajauConfigFactory from 'https://cdn.skypack.dev/@eddieajau/config-factory';
</script>

README

Node.js Config Factory

Build Status

A simple wrapper for nconf providing the ability to load configuration files in a directory.

Installation

$ npm install @eddieajau/config-factory

Example

ConfigFactory is a static factory class that can be used to create a standard nconf object. However, there are two parameters that can be passed to the createConfig function.

  • directory - The directory that contains .js or .json configuration files to load.
  • overrides - An optional path to a file that can override the properties merged from configuration directory.
var ConfigFactory = require('@eddieajau/config-factory');

var config = ConfigFactory.createConfig({
    directory: __dirname + '/etc/',
    overrides:  __dirname + '/etc/locals.js'
});

var setting = config.get('setting');

Configuration files can be either valid .js or .json. After loading, the normal nconf API can be applied.

Code quality and tests

$ npm run lint
$ npm run test

License

MIT

References