0

How to make node package (class from node_modules) injectable?

I use inversify in my app and I want to bind Validator.ts class to my container. How can I do it?

const container = new Container(); container.bind<Validator>(Validator).toSelf();

Is not enough cause I got:

Error: Missing required @injectable annotation in: Validator.

tBlabs
  • 2,619
  • 3
  • 18
  • 22

1 Answers1

0

The solution is easy:

decorate(injectable(), Validator);

or

container.bind<Validator>(Validator).toConstantValue(new Validator());

This post helped me out.

tBlabs
  • 2,619
  • 3
  • 18
  • 22