Rebind NodeRequestService

I rewrote NodeRequestService,
In the backend-module file:
rebind(RequestService).to(NodeRequestService).inSingletonScope();
But I get an error

Error: Missing required @injectable annotation in: NodeRequestService.
    at getTargets (/Users/ranwenqi/Documents/chinatelecom/ide/extensions/srdcloud-ide-init/node_modules/inversify/lib/planning/reflection_utils.js:27:15)
    at Object.getDependencies (/Users/ranwenqi/Documents/chinatelecom/ide/extensions/srdcloud-ide-init/node_modules/inversify/lib/planning/reflection_utils.js:18:19)
    at /Users/ranwenqi/Documents/chinatelecom/ide/extensions/srdcloud-ide-init/node_modules/inversify/lib/planning/planner.js:107:51
    at Array.forEach (<anonymous>)
    at _createSubRequests (/Users/ranwenqi/Documents/chinatelecom/ide/extensions/srdcloud-ide-init/node_modules/inversify/lib/planning/planner.js:95:20)
    at /Users/ranwenqi/Documents/chinatelecom/ide/extensions/srdcloud-ide-init/node_modules/inversify/lib/planning/planner.js:116:17
    at Array.forEach (<anonymous>)
    at /Users/ranwenqi/Documents/chinatelecom/ide/extensions/srdcloud-ide-init/node_modules/inversify/lib/planning/planner.js:115:26
    at Array.forEach (<anonymous>)
    at _createSubRequests (/Users/ranwenqi/Documents/chinatelecom/ide/extensions/srdcloud-ide-init/node_modules/inversify/lib/planning/planner.js:95:20)

@wenqi thank you for the discussion, NodeRequestService does not seem to be injectable and as a consequence not rebindable through inversify:


i want to add userid&sessionid to headers,What should I do?

@wenqi I’m not on my computer at the moment so I can’t try for myself but you may try to decorate your custom class before attempting to rebind:

Thank you very much. Problem solved,

what’s the use of this?

decorate(injectable(), NodeRequestService);

@wenqi it is simply annotating that class is injectable (so it can be dependency injected (ex: rebindinded)). If you have questions related to our dependency injection you can take a look at inversify itself.