Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@catalist-nestjs/fetch
Advanced tools
NestJS Fetch for Catalist Finance projects. Part of [Catalist NestJS Modules](https://github.com/blockarchivelabs/catalist-nestjs-modules/#readme)
NestJS Fetch for Catalist Finance projects. Part of Catalist NestJS Modules
The module is based on the node-fetch package.
yarn add @catalist-nestjs/fetch
// Import
import { Module } from '@nestjs/common';
import { FetchModule } from '@catalist-nestjs/fetch';
import { MyService } from './my.service';
@Module({
imports: [FetchModule.forFeature()],
providers: [MyService],
exports: [MyService],
})
export class MyModule {}
// Usage
import { FetchService } from '@catalist-nestjs/fetch';
export class MyService {
constructor(private fetchService: FetchService) {}
async myFetch() {
return await this.fetchService.fetchJson('/url');
}
}
The fetchService
provides 2 methods: fetchJson
and fetchText
, which are based on a call to the fetch
function followed by a call to .json()
or .text()
. Method arguments are compatible with the fetch
.
import { Module } from '@nestjs/common';
import { FetchModule } from '@catalist-nestjs/fetch';
@Module({
imports: [FetchModule.forRoot()],
})
export class MyModule {}
import { Module } from '@nestjs/common';
import { FetchModule } from '@catalist-nestjs/fetch';
import { ConfigModule, ConfigService } from './my.service';
@Module({
imports: [
ConfigModule,
FetchModule.forRootAsync({
async useFactory(configService: ConfigService) {
return { baseUrls: configService.baseUrls };
},
inject: [ConfigService],
}),
],
})
export class MyModule {}
The forRoot
and forFeature
methods have the same options:
export interface FetchModuleOptions {
baseUrls?: string[];
retryPolicy?: RequestRetryPolicy;
}
export interface RequestRetryPolicy {
delay?: number;
attempts?: number;
}
Option | Default | Desc |
---|---|---|
baseUrls | [] | Array of base API URLs |
delay | 1000 | Number of milliseconds between attempts |
attempts | 0 | Number of times the query is retried |
// Import
import { Module } from '@nestjs/common';
import { FetchModule } from '@catalist-nestjs/fetch';
import { MyService } from './my.service';
@Module({
imports: [
FetchModule.forFeature({
baseUrls: ['https://my-api.com', 'https://my-fallback-api.com'],
retryPolicy: {
delay: 2000,
attempts: 3,
},
}),
],
providers: [MyService],
exports: [MyService],
})
export class MyModule {}
// Usage
import { FetchService } from '@catalist-nestjs/fetch';
export class MyService {
constructor(private fetchService: FetchService) {}
async myFetch() {
return await this.fetchService.fetchJson('/foo');
}
}
If the provided API services are unavailable, the following happens:
The retryPolicy
for each query can be rewritten:
import { FetchService } from '@catalist-nestjs/fetch';
export class MyService {
constructor(private fetchService: FetchService) {}
async myFetch() {
return await this.fetchService.fetchJson('/foo', {
retryPolicy: {
delay: 2000,
attempts: 3,
},
});
}
}
FAQs
NestJS Fetch for Catalist Finance projects. Part of [Catalist NestJS Modules](https://github.com/blockarchivelabs/catalist-nestjs-modules/#readme)
The npm package @catalist-nestjs/fetch receives a total of 0 weekly downloads. As such, @catalist-nestjs/fetch popularity was classified as not popular.
We found that @catalist-nestjs/fetch demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.