I've created a NestJs project with Fastify, and have created a middleware for it, but I can't figure out how to send a response to the client, similar to how we could do in express, any help would be appreciated, thanks!, here's my middleware code:
import {
Injectable,
NestMiddleware,
HttpException,
HttpStatus,
} from '@nestjs/common';
@Injectable()
export class LoggerMiddleware implements NestMiddleware {
use(req: any, res: any, next: Function) {
console.log('Request...', res);
// throw new HttpException('Forbidden', HttpStatus.FORBIDDEN);
next();
}
}
Looks like
Fastify
abstraction uses NodeJS vanilahttp
objects (Theres
injected here is http,ServerResponse )