Skip to content

Commit

Permalink
feat: replace .toPromise() with firstValueFrom
Browse files Browse the repository at this point in the history
  • Loading branch information
Harish-osmosys committed Dec 31, 2024
1 parent 2efc840 commit 5208565
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions apps/api/src/common/logger/slogerr.transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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',
Expand All @@ -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(
Expand Down

0 comments on commit 5208565

Please sign in to comment.