import { AxiosRequestConfig , AxiosResponse } from 'axios' ; import { lastValueFrom } from 'rxjs' ; import { HttpService } from '@nestjs/axios' ; import { Injectable } from '@nestjs/common' ; import { BridgePayload , BridgeResponse } from '@fc/hybridge-http-proxy' ; import { LoggerService } from '@fc/logger' ; @ Injectable ( ) export class CsmrHttpProxyService { constructor ( private logger , private http ) { this . logger . setContext ( this . constructor . name ) ; } param { HttpProxyRequest } options returns { Promise < HttpProxyResponse > } async forwardRequest ( commands ) { this . logger . debug ( 'forwardRequest()' ) ; this . logger . trace ( { commands } ) ; const { url , method , headers : requestHeaders , data : requestData , } = commands ; const config = { headers : requestHeaders , } ; const options = [ url , requestData , config ] . filter ( Boolean ) ; const { status , statusText , headers , data } = await lastValueFrom < AxiosResponse < string > > ( this . http [ method ] ( ... options ) ) ; const response = { status , data , statusText , headers , } ; this . logger . trace ( { response } ) ; return response ; } }