node package manager


Dependency injection framework and Inversion of Control container


Overdose is a Dependency Injection mechanism that uses an Inversion of Control container to inject dependencies into Objects. The container enabled decoupling of modules and the dependencies of the module to be injected when run.

Objects can be registered with the container and the container can be told what dependencies the Object needs.

Installation goes through npm:

$ npm install overdose

Overdose does not have any dependencies except for running the tests.

Tests are written using tap and can be run with npm if all dev-dependencies are installed:

$ npm install overdose
$ npm test

If you want to run individual tests use this, where name is substituted for the test name:

$ node test/{NAME}.test.js

This module is licensed under the MIT License. See the LICENSE file for more details.


Load definition


var Container = require('overdose').Container;
var container = new Container();

Overdose exposes several ways of registering services with the container. Depending on the situation and the requirements of that situation one will fit better than the other.

There are three ways to register a service:

  • Using register for existing (instantiated) services
  • Using load to register a service from a module
  • Using provide to register a service that is instantiated by a provider function.
var myService = {
    foo: "bar"
container.register(myService, 'foo');

Using a constructor:

var httpServer = container.load({
  "name":        "httpServer",
  "module":      "http",
  "constructor": "Server"

Using a factory function:

var httpServer = container.load({
  "name":    "httpServer",
  "module":  "http",
  "factory": "createServer"