Neverending Plethora of Modules
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

ninject

0.2.0 • Public • Published

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.

install

npm i ninject

Downloadsweekly downloads

0

version

0.2.0

license

ISC

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability