Thanks to visit codestin.com
Credit goes to github.com

Skip to content

bamada/nestjs-http-retry

Repository files navigation

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.

TODO

  • Implementation of other http methods (Post, Put, Delete, Patch)
  • Add more retry strategies

Contributors ✨

madcam
madcam

⚠️ 💻 📖 🐛

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •