import { CallHandler, ExecutionContext, Injectable, NestInterceptor, } from '@nestjs/common'; import { Observable } from 'rxjs'; import { tap } from 'rxjs/operators'; @Injectable() export class ResponseTimeInterceptor implements NestInterceptor { intercept(context: ExecutionContext, next: CallHandler): Observable { console.log('Before...'); const start = Date.now(); return next .handle() .pipe(tap(() => console.log(`Response time: ${Date.now() - start}ms`))); } }