IoC for Javascript & Node.js

IoC container for Javascript / Node.js

Noder.io provides a lightweight and flexible core to create a scalable API of a lib, a module, an application or a framework. Noder.io is inspired (among others) by Angular and Pimple.
It is useful for starting a project quickly with a modular API ready to use.

Noder.io (and any object built on top of Noder.io) integrates:

No dependencies, works on Node.js and in the browser (only 7kb). Noder.io is an Open Source project, free to use under MIT licence.

Quickstart

Quick example:


var api = noder.createNoder();
var db;

api.$di.set('config', {
  name: 'My great app',
  email: 'contact@domain.tld'
});

// shortcut of api.$di.factory()
api.$factory('db', '$container', function(ctn) {
  var dbService;

  // factory function body that constructs `db` service (database handler)

  // `$container` (ctn) is `api.$di._container`
  console.log(ctn === api.$di._container);

  // so: ctn.config.name, ctn.config.email

  return dbService;
});

// by getter
db = api.$di.get('db');

// by injection in another service constructor

function articleHandler(db, config) {
  // body of article handler ...
}

api.$factory('article', ['db', 'config'], articleHandler);

// by binding (shortcut of api.$di.apply())
var welcome = api.$apply(function() {

  // the scope (`this`) bind to `api.$di._container`
  return 'Welcome in ' + this.config.name +
    'contact: ' + this.config.email;
});