NodeJS Plugin <fl-node-di>

NodeJS Plugin <fl-node-di>

Published on: 9/14/2018

Installation

Add the package located at npmjs to your project
npm i --save fl-node-di # or yarn add fl-node-di
Import the decorators with
import { FlModule, Component, Injectable, Inject } from 'fl-node-di'

Usage

Hierarchical NodeJS dependency injection module on top of inversify for using backend DI in a way similar to Angulars DI. E.g. you can use the following snippet throughout your complete application
@FlModule({ imports: [ AuthModule, Http2Module ], declarations: [ AppComponent ], providers: [ AuthService ], exports: [ ] }) export class AppModule {}
The other two decorators are
@Component() export class AppComponent {}
which treats the decorator as an inversify @injectable and directly creates an instance when the parent module gets instanciated. The other one is the @Injectable() decorator
@Injectable() export class AuthService {}
which returns an inversify @injectable decorator, but does not directly creates an instance but instanciates itself when an @Inject(serviceIdentifier) is used as a constructor parameter in the same or a childs containers class.