Dependency injector for Express controllers using di.js

Usage no npm install needed!

<script type="module">
  import expressDependencyInjector from '';



Build Status

Dependency injector for Express using di.js (

NPM Location

Binding Dependencies

var express = require('express');

var application = express();


application.bind(MyObject, [Dependency1, Dependency2], 'singleton')

Resolving Dependencies

var myObject = req.dependencyInjector.get(MyObject);

Valid Scopes

// singleton, webrequest, transient

application.bind(MyObject, [Dependency1, Dependency2], 'singleton');

application.bind(MyObject, [Dependency1, Dependency2], 'webrequest');

application.bind(MyObject, [Dependency1, Dependency2], 'transient');

Dependency Objects

All objects and dependencies must follow the constructor pattern. The di.js library makes new instances of these objects when they are requested. You use the scope parameter on the bind function to control how often a new instance is created when you request your object.

See the following link for details and examples of the constructor pattern:

Example Project

Run Tests Command

npm test