我用 Fastify 创建了一个 NestJs 项目,并为其创建了一个中间件,但我不知道如何向客户端发送响应,类似于我们在 Express 中的做法,任何帮助将不胜感激,谢谢!,这是我的中间件代码:
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();
}
}
Run Code Online (Sandbox Code Playgroud)