0.0.1 • Published 5 years ago
@prodigylabs/identity-core-config v0.0.1
Info
Core module which provides a common functionality like dependency injection, logging, error handling
Dependency Injection
Key points: 1. We use node-dependency-injection as a dependency injection engine 2. Dependency injection is resolved automatically, all you need to have is to add injections.yml, similar to this
services:
controller.index:
class: ./controllers/index.controller
It will create a class located in ./controllers/index.controller.ts
and store it by this key controller.index
3. If it is necessary, injected dependency can be retrieved next way
import {injector} from 'identity-core-common';
... // Not relevant code omitted for clarity
let indexController: IndexController = injector.get('controller.index');
... // Not relevant code omitted for clarity
Note
Such way of dependency injection resembles more service locator pattern with all of it advantages and disadvantages, but gives an effective and simple way to decouple dependency injection from the codebase
0.0.1
5 years ago