NestJS: Can the moduleRef instance be accessed using the ExecutionContext?

Viewed 342

need your help with a NestJS related "thingy".

Context:

  • I have a Guard called RequirePermission
  • I pre-instantiate the guard before applying it: new RequirePermission('list.user')
  • at this point, I loose the NestJS baked-in DI feature so I can't inject things into the Guard anymore
  • the canActivate method is getting an instance of the ExecutionContext

Question:

  • How can I get a hold of the moduleRef instance by using the ctx: ExecutionContext object

PS: please don't try to buy me into the SetMetadata approach :) (not saying this approach is bad)

0 Answers
Related