Injection

A lightweight inversion of control container for Node.js apps

Quickly Start →

$ npm install injection reflect-metadata --save

Injection requires TypeScript >= 2.0 and the experimentalDecorators, emitDecoratorMetadata, types and lib compilation options in your tsconfig.json file.

{
  "compilerOptions": {
    "target": "ES2017",
    "lib": ["es2017", "dom"],
    "types": ["reflect-metadata"],
    "module": "commonjs",
    "moduleResolution": "node",
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true
  }
}

COMPATIBILITY NOTE

midway requires Node.js >= 8.

Features

Code decoupling

IOC is now a popular practice in the industry. It is used in node. js applications, which allows the application code to be decoupled and measurable. in the development process, there is no need to care about instantiation and destruction.

Easy to expand

Injection provides the basic container object, which can be encapsulated at multiple levels, such as requestcontainer, and we also provide convenient decoration extension capabilities, simplifies complex parameters when defining a decorator.

Framework Integration

As a basic IOC container, injection can be very convenient to access different framework systems. In addition to the midway we developed, it can be applied to different frameworks such as Koa, thinkjs.