我正在使用@golevelup/nestjs-rabbitmq
来处理来自队列的RabbitMQ消息,全局防护正在拦截来自队列的请求。有什么方法可以阻止全局防护获取这些请求吗?
身份验证防护
@Injectable()
export default class GqlAuthGuard extends AuthGuard(AuthStrategy.Jwt) {
constructor(private reflector: Reflector) {
super();
}
getRequest(context: ExecutionContext) {
const ctx = GqlExecutionContext.create(context);
return ctx.getContext();
}
canActivate(context: ExecutionContext) {
const isPublic = this.reflector.getAllAndOverride<boolean>(IS_PUBLIC_KEY, [
context.getHandler(),
context.getClass(),
]);
if (isPublic) {
return true;
}
return super.canActivate(context);
}
}
RabbitMQ订阅者
@SubscribeToEvent({
queue: Topic.SendSurvey,
})
async handler({ surveyId, schedulingEventId }: HandlerParams) {
this.logger.info('Handling message', surveyId, schedulingEventId);
this.surveysService.dispatch(surveyId, schedulingEventId);
}
我得到的错误
[22-03-24 02:52:31] [error] [app] TypeError: Cannot read properties of undefined (reading 'req') {"0":"MotivatoExceptionsHandler"}
[22-03-24 02:52:31] [error] [app] TypeError: Cannot read properties of undefined (reading 'req') {"0":"MotivatoExceptionsHandler"}
[22-03-24 02:52:31] [error] [app] TypeError: Cannot read properties of undefined (reading 'req') {"0":"MotivatoExceptionsHandler"}
[22-03-24 02:52:31] [error] [app] TypeError: Cannot read properties of undefined (reading 'req') {"0":"MotivatoExceptionsHandler"}
我尝试更改getRequest
,但不起作用
1条答案
按热度按时间z9zf31ra1#
以这种方式添加时有效