Gathering detailed insights and metrics for @sgfe/axios
Gathering detailed insights and metrics for @sgfe/axios
Gathering detailed insights and metrics for @sgfe/axios
Gathering detailed insights and metrics for @sgfe/axios
npm install @sgfe/axios
Typescript
Module System
Node Version
NPM Version
53.6
Supply Chain
97.6
Quality
75.4
Maintenance
100
Vulnerability
99.6
License
Cumulative downloads
Total Downloads
Last day
0%
0
Compared to previous day
Last week
0%
0
Compared to previous week
Last month
0%
0
Compared to previous month
Last year
0%
0
Compared to previous year
1
3
nestjs module that just doing little modification to the original and good nestjs http module.
.toPromise()
every http call.{ retries: NUMBER_OF_RETRIES }
in the config of the http module.
more details in the configuration sectionUsing npm:
$ npm install nestjs-http-promise
Using yarn:
$ yarn add nestjs-http-promise
import the module:
1import { HttpModule } from 'nestjs-http-promise' 2 3@Module({ 4 imports: [HttpModule] 5})
inject the service in the class:
1import { HttpService } from 'nestjs-http-promise' 2 3class Demo { 4 constructor(private readonly httpService: HttpService) {} 5}
use the service:
1public callSomeServer(): Promise<object> { 2 return this.httpService.get('http://fakeService') 3}
the service uses axios and axios-retry, so you can pass any AxiosRequestConfig And/Or AxiosRetryConfig
just pass it in the .register()
method as you would do in the original nestjs httpModule
1import { HttpModule } from 'nestjs-http-promise' 2 3@Module({ 4 imports: [HttpModule.register( 5 { 6 timeout: 1000, 7 retries: 5, 8 ... 9 } 10 )] 11})
When you need to pass module options asynchronously instead of statically, use the registerAsync()
method just like in nest httpModule.
you have a couple of techniques to do it:
1HttpModule.registerAsync({ 2 useFactory: () => ({ 3 timeout: 1000, 4 retries: 5, 5 ... 6 }), 7});
1HttpModule.registerAsync({
2 useClass: HttpConfigService,
3});
Note that in this example, the HttpConfigService has to implement HttpModuleOptionsFactory interface as shown below.
1@Injectable() 2class HttpConfigService implements HttpModuleOptionsFactory { 3 async createHttpOptions(): Promise<HttpModuleOptions> { 4 const configurationData = await someAsyncMethod(); 5 return { 6 timeout: configurationData.timeout, 7 retries: 5, 8 ... 9 }; 10 } 11}
If you want to reuse an existing options provider instead of creating a copy inside the HttpModule, use the useExisting syntax.
1HttpModule.registerAsync({ 2 imports: [ConfigModule], 3 useExisting: ConfigService, 4});
No vulnerabilities found.
No security vulnerabilities found.