@bamada/nestjs-http-retry
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

NestJS HTTP Retry Module Logo

A resilient NestJS module to handle HTTP requests with configurable retry strategies.

code style: prettier


Table of Contents


Description

This module integrates an HTTP retry functionality into the NestJS framework, providing configurable retry strategies like Exponential Backoff or Constant Interval retries.

Features

The NestJS HTTP Retry module supports these key features:

  • Easy-to-use configurable retry strategies
  • Exponential Backoff retries
  • Constant Interval retries
  • No-retry option

Installation

You can install the module using yarn or npm:

$ yarn add @bamada/nestjs-http-retry

OR

$ npm i @bamada/nestjs-http-retry

Configuration

To configure the retry strategies, pass the desired settings when registering the module:

import {
  HttpRetryStrategiesModule,
  RetryStrategyType,
} from '@bamada/nestjs-http-retry';

@Module({
  imports: [
    HttpRetryStrategiesModule.register({
      type: RetryStrategyType.Interval,
      maxAttempts: 3,
      intervalMs: 1000,
    }),
  ],
  // Other module properties
})
export class AppModule {}

Usage

Once configured, use the HttpRetryStrategiesService to make HTTP requests with the built-in retry strategies.

Examples

Below is a simple example of how to use the HTTP Retry Strategies service:

import { Injectable } from '@nestjs/common';
import { HttpRetryStrategiesService } from '@bamada/nestjs-http-retry';

@Injectable()
export class YourService {
  constructor(private readonly httpRetryService: HttpRetryStrategiesService) {}

  async getResource() {
    return this.httpRetryService.get('https://your.api/resource').toPromise();
  }
}

Contribute & Disclaimer

Feel free to contribute by submitting pull requests or opening issues. This module comes with no warranty; use it at your own risk.

License

Distributed under the MIT License. See LICENSE for more information.

Contributors ✨

madcam
madcam

⚠️ 💻 📖 🐛

This project follows the all-contributors specification. Contributions of any kind welcome!

Package Sidebar

Install

npm i @bamada/nestjs-http-retry

Weekly Downloads

9

Version

0.1.2

License

MIT

Unpacked Size

3.2 MB

Total Files

26

Last publish

Collaborators

  • bamada