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.
The solution is easy:
decorate(injectable(), Validator);
or
container.bind<Validator>(Validator).toConstantValue(new Validator());
This post helped me out.