forked from Yara724/api
Initial commit after migration to gitea
This commit is contained in:
20
src/interceptor/logging.interceptors.ts
Normal file
20
src/interceptor/logging.interceptors.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import {
|
||||
Injectable,
|
||||
NestInterceptor,
|
||||
ExecutionContext,
|
||||
CallHandler,
|
||||
} from "@nestjs/common";
|
||||
import { Observable } from "rxjs";
|
||||
import { tap } from "rxjs/operators";
|
||||
|
||||
@Injectable()
|
||||
export class LoggingInterceptor implements NestInterceptor {
|
||||
intercept(context: ExecutionContext, next: CallHandler): Observable<any> {
|
||||
console.log("Before...");
|
||||
|
||||
const now = Date.now();
|
||||
return next
|
||||
.handle()
|
||||
.pipe(tap(() => console.log(`After... ${Date.now() - now}ms`)));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user