0.2.0 • Published 10 years ago

ninject v0.2.0

Weekly downloads
4
License
ISC
Repository
github
Last release
10 years ago

ninject

Node Dependency Injection

var config = require('ninject')('config');

##init Should be run in your application's entry point before any require statements.

require('ninject').init(options);

  • options
    • K/V pairs where the key is the require name and the value is the path to the file.
    • The path is from the file where you have initialised.
//ProjectRoot
// |-example.js 
// |-config.js
// |-Controllers
//   |-home.js
//   |-account.js


var options = {
  config: './config',
  HomeController: './Controllers/home',
  AccountController: './Controllers/account'
}

require('ninject').init(options);
//...the rest of your startup can continue now...

##register

External registrations can be made once the init has run by performing a register.

require('ninject').register(packageName, packagePath);

  • packageName - the name to use when ninjecting
  • packagePath - The path to the package.