mirror of
https://github.com/Maks1mS/nestjs-telegraf.git
synced 2024-12-27 16:18:10 +03:00
21 lines
511 B
TypeScript
21 lines
511 B
TypeScript
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<any> {
|
|
console.log('Before...');
|
|
|
|
const start = Date.now();
|
|
return next
|
|
.handle()
|
|
.pipe(tap(() => console.log(`Response time: ${Date.now() - start}ms`)));
|
|
}
|
|
}
|