From 5208565608d4e2fc96db94386faa923c3f374649 Mon Sep 17 00:00:00 2001 From: Harish-osmosys <121787291+Harish-osmosys@users.noreply.github.com> Date: Tue, 31 Dec 2024 10:55:16 +0530 Subject: [PATCH] feat: replace .toPromise() with firstValueFrom --- apps/api/src/common/logger/slogerr.transport.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/api/src/common/logger/slogerr.transport.ts b/apps/api/src/common/logger/slogerr.transport.ts index fb1cc039..c1090507 100644 --- a/apps/api/src/common/logger/slogerr.transport.ts +++ b/apps/api/src/common/logger/slogerr.transport.ts @@ -3,6 +3,7 @@ import TransportStream = require('winston-transport'); import { TransportStreamOptions } from 'winston-transport'; import { ConfigService } from '@nestjs/config'; import { Logger } from '@nestjs/common/services/logger.service'; +import { firstValueFrom } from 'rxjs'; interface CustomTransportOptions extends TransportStreamOptions { httpService: HttpService; @@ -44,8 +45,8 @@ export class SlogerrTransport extends TransportStream { const logCreatedOn = info.timestamp || new Date().toISOString(); try { - const response = await this.httpService - .post( + const response = await firstValueFrom( + this.httpService.post( apiEndpoint, { moduleName: info.context || 'Unknown Module', @@ -60,8 +61,8 @@ export class SlogerrTransport extends TransportStream { }, }, { headers: { 'slogerr-secure-api-key': apiKey } }, - ) - .toPromise(); // Convert Observable to Promise + ), + ); if (response.status !== 200) { this.logger.error(