npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

fastfetch-api-fetch-enhancer

v2.0.0

Published

Production-grade HTTP client with circuit breakers, concurrency queues, metrics, SSE streaming, and typed errors.

Readme

FastFetch API Enhancer

FastFetch is a production-grade, enterprise-ready HTTP client built around the native fetch API. It transforms simple HTTP requests into robust network architecture by introducing advanced resilience patterns, high-concurrency request management, and real-time streaming capabilities without excessive boilerplate.

Architecture & Features

FastFetch v2 provides seven core execution pipelines directly into your fetch workflow:

  • Strict Typed Error Hierarchy: Explicit errors for TimeoutError, NetworkError, HttpError, and CircuitOpenError enabling robust try/catch control flow.
  • Koa-Style Middleware Pipeline: A powerful .use(async (ctx, next) => {}) onion-model interceptor architecture for modifying request metadata or observing response execution duration.
  • Finite State Machine Circuit Breaker: Stops cascading failures to downstream services by automatically failing fast when failure thresholds are breached, entering a HALF_OPEN state after the configured timeout.
  • Priority-Aware Concurrency Queue: Protects API rate limits by enforcing a strict maxConcurrent ceiling across all ongoing requests while maintaining execution priority.
  • Offline Mutation Buffering: Automatically buffers mutating requests (POST, PUT, PATCH, DELETE) internally if the browser detects an offline state, sequentially replaying them upon reconnection.
  • Real-Time Telemetry & Metrics: Maintains rolling windows on p50, p95, and p99 latency percentiles alongside exact endpoint success and failure ratios.
  • Server-Sent Events (SSE) Native Streaming: A built-in high-performance stream consumer utilizing api.stream() for interacting with AI models and event-driven backends natively over HTTP.

Installation

npm install fastfetch-api-fetch-enhancer

Basic Usage

A minimal example utilizing the createClient factory method:

import { createClient } from 'fastfetch-api-fetch-enhancer';

// Instantiate your global HTTP client
const api = createClient({
  baseURL: 'https://api.example.com/v1',
  headers: { 'Authorization': 'Bearer <token>' },
  timeout: 10000,
  retries: 3,
  retryDelay: 1000,
  maxConcurrent: 50,
  circuitBreaker: {
    threshold: 5,
    timeout: 30000
  }
});

// Koa-style middleware injection
api.use(async (ctx, next) => {
  ctx.init.headers['X-Request-Id'] = crypto.randomUUID();
  await next();
  console.log(`[HTTP ${ctx.response?.status}] ${ctx.method} ${ctx.url} - ${ctx.duration}ms`);
});

// Start making requests
async function execute() {
  try {
    // Standard JSON shorthand
    const user = await api.json('/users/me');
    
    // Auto-serialization for payload delivery
    await api.post('/events', { action: 'login', timestamp: Date.now() });
    
  } catch (error) {
    // Typed catch boundaries
    if (error instanceof HttpError) {
      console.error('API Rejected Request:', error.status);
    } else if (error instanceof TimeoutError) {
      console.error('Request timed out at:', error.timeout);
    } else {
      console.error('Catastrophic failure:', error);
    }
  }
}

Advanced Streaming (SSE)

Consume AI generation pipelines directly over HTTP using the stream handler:

const signal = new AbortController();

await api.stream(
  '/ai/generate-text',
  (event) => {
    process.stdout.write(event.data);
  },
  { signal: signal.signal }
);

Monitoring & Telemetry

Evaluate application stability at any time by accessing the built-in system telemetry map:

const telemetry = api.metrics.snapshot();
console.table(telemetry.byEndpoint);
console.log('p99 global latency:', telemetry.globalLatencies.p99);

License

FastFetch is open-source software licensed under the MIT License.