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

ai-fetch-healer

v1.0.2

Published

Runtime API Auto-Healing Wrapper

Readme

ai-fetch-healer

Production-ready runtime API auto-healing for JavaScript and TypeScript applications.

ai-fetch-healer helps your app stay resilient when upstream API contracts change unexpectedly. Instead of shipping an emergency patch immediately, your client can detect schema mismatch patterns, apply healing rules, and keep critical flows alive.

Why It Matters

Upstream APIs change. Field names drift, required keys move, and error payloads evolve. These changes often surface at the worst possible time, turning into late-night incidents and manual rollbacks.

ai-fetch-healer is designed to reduce those 3 AM production calls by:

  • intercepting failed requests (for healing-eligible statuses),
  • generating a safe schema-based healing rule,
  • applying the fix automatically,
  • caching the rule for fast follow-up requests.

The result is better uptime, fewer emergency hotfixes, and a smoother on-call experience.

Supported Providers

  • GeminiProvider
  • OpenRouterProvider

Planned Support / Roadmap

  • GroqProvider
  • OllamaProvider

Quick Start

pnpm add ai-fetch-healer
import { createHealedFetch, OpenRouterProvider } from 'ai-fetch-healer';

const provider = new OpenRouterProvider();
const healedFetch = createHealedFetch(provider);

const response = await healedFetch('https://api.example.com/data', {
  method: 'POST',
  body: JSON.stringify({ user_name: 'Code' }),
});

Smart Configuration

OpenRouterProvider supports smart API key resolution in this priority order:

  1. apiKey passed to constructor
  2. options.apiKey in constructor options
  3. AI_HEALER_OPENROUTER_KEY
  4. OPENROUTER_API_KEY
  5. GEMINI_API_KEY (legacy fallback)
AI_HEALER_OPENROUTER_KEY=your_openrouter_key_here

Constructor flexibility:

import { OpenRouterProvider } from 'ai-fetch-healer';

const fromEnv = new OpenRouterProvider();

const withKeyAndOptions = new OpenRouterProvider('YOUR_KEY', {
  model: 'google/gemini-2.0-flash-001',
  timeoutMs: 5000,
});

const optionsOnly = new OpenRouterProvider({
  apiKey: 'YOUR_KEY',
  model: 'google/gemini-2.0-flash-001',
  timeoutMs: 5000,
});

Resilience & Timeouts

ai-fetch-healer uses an Abort-based timeout strategy with AbortController to prevent hanging provider calls.

  • Default timeout: 10000ms (10 seconds)
  • If timeout is reached: healing is aborted and the original API response is returned to preserve availability.
import { OpenRouterProvider } from 'ai-fetch-healer';

const provider = new OpenRouterProvider('YOUR_KEY', {
  model: 'google/gemini-2.0-flash-001',
  timeoutMs: 5000,
});

Security & Privacy (The Masker)

ai-fetch-healer follows Privacy-by-Design principles. Before any healing analysis, payloads are recursively masked so only schema-safe signals are sent to LLM providers.

Sensitive Key Defaults

| Category | Default Sensitive Keys | Example Mask Output | | --- | --- | --- | | Identity | email, phone, username | masked_email, masked_phone, masked_identity | | Credentials | password, token, api_key | masked_password, masked_token | | Financial | credit_card, bank_account | masked_credit_card, masked_financial |

Compliance & Privacy

PDPA & GDPR Ready: ai-fetch-healer ensures no PII is transmitted to LLM providers by using schema-only analysis with recursive masking.

Custom Masker for Enterprise Fields

import { createHealedFetch, Masker, OpenRouterProvider } from 'ai-fetch-healer';

const provider = new OpenRouterProvider();

const customMasker = new Masker({
  additionalSensitiveKeys: ['customer_id', 'internal_secret'],
  maskingString: '[PROTECTED_DATA]',
});

const healedFetch = createHealedFetch(provider, { masker: customMasker });

Performance & Memory Safety

ai-fetch-healer includes a heuristic cache for healing rules to minimize repeated provider calls.

  • Lookup complexity: O(1) via map-based key access
  • Bounded capacity: 1,000 rules by default
  • Safety behavior: oldest entries are evicted when capacity is reached

This design keeps repeated healing fast while preventing unbounded memory growth in long-running services.