Dynamic injection based on request parameter/ header in controller using InversifyJS

170 views Asked by At

I am exploring InversifyJS in TypeScript and I want to understand if InversifyJS will work for my use case.

I have a TypeScript project with serverless lambda, Koa. I want to integrate InversifyJS and work on dynamic dependency injection, i.e., with every request, I will get a channel ID.

And based on channelId I want to bind the specific implementation in service layer. Does InversifyJS support this? Which place is the best place to bind the dynamic implementation? Middleware or controller? The InversifyJS container is created even before the server starts, so binding it there is not possible as I have access to the channelId variable in middleware and after that. Does InversifyJS support dynamic injection?

0

There are 0 answers