Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Dependency Injection / Inversion of Control module for node.js
JavaScript
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
test
.gitignore
.travis.yml
LICENSE.md
README.md
index.js
package.json

README.md

conga-dependency-injection Build Status

Overview

Installation

> npm install conga-dependency-injection

Usage

Configuration Example

var config = {

  // set up some parameters
  "parameters" : [
      "my.service.constructor" : "path/to/some/service/file",
      "fs.service.constructor" : "fs"
  ],

  // set up services
  "services" : [
      {
          "id" : "fs.service",
          "constructor" : "%fs.service.constructor%"
      },
      {
          "id" : "my.service",
          "constructor" : "%my.service.constructor%",
          "arguments" : ["@fs.service"]
      }
  ]
};

Creating a container

// require the module
var di = require('conga-dependency-injection');

// create a service loader
var loader = new di.ServiceLoader();

// create a container builder with the loader
var builder = new di.ContainerBuilder(loader);

// build the container and retrieve it in a callback
builder.build(config, function(container){
    var service = container.get('my.service');
});
Something went wrong with that request. Please try again.