cfg.me
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

cfg.me

Configuration loader for nodejs apps.

Loads configuration from provided JSON file into an immutable object accesible with get() function.

Can be used by both typescript and javascript apps.

Installation

npm install cfg.me

Usage

JS

// Starting module
var cfgMe = require('cfg.me');

// Must be called before any subsequent `get()` calls
var cfg = cfgMe.load('./path/to/config.json');
// Some other module
var cfgMe = require('cfg.me');

function some() {
  // Do not use this at module level as it will throw if called before `load()`
  var cfg = cfgMe.get();
  var value = cfg.some.property;
}

Typescript

// Starting module
import * as cfgMe from 'cfg.me';

// Must be called before any subsequent `get()` calls
let cfg = cfgMe.load<CfgClass>('./path/to/config.json');
// Some other module
import * as cfgMe from 'cfg.me';

function some() {
  // Do not use this at module level as it will throw if called before `load()`
  ley cfg = cfgMe.get<CfgClass>();
  let value = cfg.some.property;
}

Readme

Keywords

Package Sidebar

Install

npm i cfg.me

Weekly Downloads

0

Version

0.0.1

License

MIT

Last publish

Collaborators

  • nyrkovalex