0.1.1 • Published 8 years ago

mumba-config v0.1.1

Weekly downloads
103
License
Apache-2.0
Repository
gitlab
Last release
8 years ago

Mumba Config

A very simple configuration handler in the tradition of nconf.

Installation

$ npm install mumba-config

Examples

import {Config} from "mumba-config";

let config = new Config({
  db: {
    user: 'user',
    pass: 'password'
  }
});

config.get();          // { db: { user: 'user', pass: 'password' } }
config.get('db');      // { user: 'user', pass: 'password' }
config.get('db:user'); // 'user'
config.get('db:pass'); // 'password'

config.set('log:level', 'silly');

Loading a file or directory

import {Config, FileLoader, DirectoryLoader} from "mumba-config";

let config = new Config();

config.registerLoader(new FileLoader())
	.registerLoader(new DirectoryLoader());

config.load([{
		name: 'file',
		filePath: '/path/to/file.json'
	},
	{
		name: 'directory',
		dirPath: 'path/to/dir',
		exclude: 'local\.js'
	}])
	.then(() => {
		console.log(config.get())
	})
	.catch(console.error);

Loaders

File

Loads a JavaScript or JSON configuration file.

ParameterTypeDescription
typestringRequired Must be set to file.
filePathstringRequired The full path to the configuration file to load.

Directory

Loads a directory of JavaScript or JSON files.

ParameterTypeDescription
typestringRequired Must be set to file.
dirPathstringRequired The full path to directory containing the configuration files.
excludestringAn optional regular expression for files to exclude from the directory.

Tests

To run the test suite, first install the dependencies, then run npm test:

$ npm install
$ npm test

People

The original author of Mumba Config is Andrew Eddie.

License

Apache 2.0


© 2016 Mumba Pty Ltd. All rights reserved.