11import { Injectable , Logger } from '@nestjs/common' ;
2- import { catchError , firstValueFrom , timeout } from 'rxjs' ;
2+ import { catchError , finalize , firstValueFrom } from 'rxjs' ;
33import { HttpService } from '@nestjs/axios' ;
44import * as blake from 'blakejs' ;
5- import { AxiosRequestConfig } from 'axios' ;
65import * as jsonld from 'jsonld' ;
76
87import { ValidateMetadataDTO } from '@dto' ;
98import { LoggerMessage , MetadataValidationStatus } from '@enums' ;
109import { validateMetadataStandard , parseMetadata , getStandard } from '@utils' ;
1110import { ValidateMetadataResult } from '@types' ;
1211
13- const axiosConfig : AxiosRequestConfig = {
14- timeout : 5000 ,
15- maxContentLength : 10 * 1024 * 1024 , // Max content length 10MB
16- maxBodyLength : 10 * 1024 * 1024 , // Max body length 10MB
17- responseType : 'text' ,
18- } ;
19-
2012@Injectable ( )
2113export class AppService {
2214 constructor ( private readonly httpService : HttpService ) { }
@@ -30,9 +22,10 @@ export class AppService {
3022
3123 try {
3224 const { data : rawData } = await firstValueFrom (
33- this . httpService . get ( url , axiosConfig ) . pipe (
34- timeout ( 5000 ) ,
35- catchError ( ( ) => {
25+ this . httpService . get ( url ) . pipe (
26+ finalize ( ( ) => Logger . log ( `Fetching ${ url } completed` ) ) ,
27+ catchError ( ( error ) => {
28+ Logger . error ( error , JSON . stringify ( error ) ) ;
3629 throw MetadataValidationStatus . URL_NOT_FOUND ;
3730 } ) ,
3831 ) ,
0 commit comments