Can anyone tell me if a fastify request is immutable? I have a middleware where I bind a user object to the request
async use(
req: FastifyRequest['raw'],
_res: FastifyReply['raw'],
next: () => void,
): Promise<void> {
...
req['user'] = user;
this.log.debug({message: 'Success', data: req['user']});
return next();
}
and in the logs I can see that the req contains the user here as expected, but when I try to access it in the controller as
async foo(
@Body() body: OnboardRequestDto,
@Req() req: FastifyRequest,
): Promise<FooResponseDto> {
console.log(req['user'])
its undefined. Any ideas what am I doing wrong?