Skip to content

Instantly share code, notes, and snippets.

@Vatsalya-singhi
Created March 27, 2025 18:29
Show Gist options
  • Save Vatsalya-singhi/f112b218b93ee345447b9d5ac654f5d8 to your computer and use it in GitHub Desktop.
Save Vatsalya-singhi/f112b218b93ee345447b9d5ac654f5d8 to your computer and use it in GitHub Desktop.
import { Injectable, NestMiddleware } from '@nestjs/common';
import { Request, Response, NextFunction } from 'express';
@Injectable()
export class LoggerMiddleware implements NestMiddleware {
use(req: Request, res: Response, next: NextFunction) {
console.log(`[${new Date().toISOString()}] ${req.method} ${req.url}`);
next(); // Pass control to the next handler
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment