You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
610 B
19 lines
610 B
import { Injectable, NestMiddleware, RequestMethod } from '@nestjs/common';
|
|
import { Request, Response, NextFunction } from 'express';
|
|
import { RouteInfo } from '@nestjs/common/interfaces';
|
|
import { request } from 'http';
|
|
@Injectable()
|
|
export class LoggerMiddleware implements NestMiddleware {
|
|
use(req: Request, res: Response, next: NextFunction) {
|
|
// Gets the request log
|
|
console.log(`req:`, {
|
|
headers: req.headers,
|
|
body: req.body,
|
|
originalUrl: req.originalUrl,
|
|
});
|
|
// Ends middleware function execution, hence allowing to move on
|
|
if (next) {
|
|
next();
|
|
}
|
|
}
|
|
}
|