Supra HTTP Client with Circuit Breaking

1.8.5 · maintenance · verified Wed Apr 22

Supra-http is a fast HTTP client for Node.js that integrates a circuit breaker pattern to enhance resilience in distributed systems. It is built on top of the 'opossum' library for robust circuit breaking capabilities, allowing it to gracefully handle failures in remote services and prevent cascading outages. The package is currently at version 1.8.5. While the project description mentions forthcoming documentation, the last update on GitHub was in March 2023, and the last npm publish was also over a year ago, suggesting a maintenance or possibly abandoned status rather than active development. Its key differentiators include built-in circuit breaking and reported performance advantages over alternatives like `request` and `requestretry` according to its benchmarks. It supports gzip and brotli decompression for Node.js versions 10.17.x and above.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to instantiate `supra-http` and make a GET request to a public API with explicit circuit breaker configuration, including error handling for when the circuit trips or the request fails.

import SupraClient from 'supra-http';

const client = new SupraClient();

async function fetchData() {
  try {
    // Example GET request with basic circuit breaking options
    const response = await client.request('myApiGetCall', 'https://jsonplaceholder.typicode.com/todos/1', {
      method: 'get',
      json: true,
      timeout: 2000, // Request timeout
      errorThresholdPercentage: 50, // 50% errors to trip the circuit
      resetTimeout: 10000, // How long to wait before trying again (half-open state)
      enabled: true // Enable circuit breaker for this call
    });
    console.log('API Response:', response.json);
  } catch (error) {
    console.error('API Call Failed or Circuit Tripped:', error.message);
    // Implement fallback logic here if needed
  }
}

fetchData();

view raw JSON →