Make node package injectable

105 views Asked by At

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.

1

There are 1 answers

0
tBlabs On

The solution is easy:

decorate(injectable(), Validator);

or

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

This post helped me out.