import {
Injectable,
NestInterceptor,
ExecutionContext,
CallHandler,
Scope,
} from '@nestjs/common';
import { log, trace } from 'console';
import { Request} from 'express';
import { Observable } from 'rxjs';
import { tap } from 'rxjs/operators';
import { WinstonLoggerService } from 'src/common/loggers/winston-logger.service';
@Injectable()
export class LoggingInterceptor implements NestInterceptor {
private readonly logger = new WinstonLoggerService(LoggingInterceptor.name)
intercept(context: ExecutionContext, next: CallHandler): Observable<any> {
let req: Request = context.switchToHttp().getRequest()
const message = {
traceId: req.body.traceId,
path: req.path,
method: req.method,
headers: req.headers,
body: req.body,
params: req.params,
query: req.query
}
const data = {
message: JSON.stringify(message)
}
return next.handle().pipe(tap(() => this.logger.log(data)))
}
}
But this code only handles http requests and responses. how do I handle websocket requests and responses?