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

@nvdigitalsolutions/nvoos-http-client

v0.1.0-alpha.3

Published

Resilient HTTP client with automatic retry, exponential backoff, and request hooks - Extracted from NV Open Operator System

Downloads

108

Readme

@nvdigitalsolutions/nvoos-http-client

Resilient HTTP client with automatic retry, exponential backoff, and request/response hooks — extracted from the NV Open Operator System WordPress plugin.

Built on ky — a lightweight, modern fetch wrapper.

Why this package?

Raw fetch has no retry logic. Network hiccups, temporary server errors (502, 503), and rate limits (429) all silently fail. This package wraps ky with production-proven defaults so you get resilience out of the box.

Installation

npm install @nvdigitalsolutions/nvoos-http-client ky

ky is a peer dependency — install it alongside this package.

Quick Start

import { postJson, get } from '@nvdigitalsolutions/nvoos-http-client';

// POST with automatic retry (3 attempts, exponential backoff)
const response = await postJson(
  'https://api.example.com/chat',
  { message: 'Hello AI' },
  { 'Authorization': 'Bearer token' }
);
const data = await response.json();

// GET with abort signal for cancellation
const controller = new AbortController();
const response = await get(
  'https://api.example.com/status',
  {},
  { signal: controller.signal, timeout: 5000 }
);

API

createHttpClient(options?)

Creates a configured ky instance with retry and hooks.

import { createHttpClient } from '@nvdigitalsolutions/nvoos-http-client';

const client = createHttpClient({
  timeout: 15000,         // 15 second timeout
  retryLimit: 5,          // retry up to 5 times
  onRetry: ({ url, retryCount }) => {
    console.log(`Retrying ${url} (attempt ${retryCount})`);
  },
  onAuthFailure: ({ url, status }) => {
    // Called on 401 — refresh token and retry
    refreshAuthToken();
  }
});

const response = await client.post('https://api.example.com/data', { json: payload });

postJson(url, data, headers?, options?)

POST JSON with retry. Returns a Response promise.

const response = await postJson(url, { key: 'value' }, headers, {
  timeout: 30000,
  retryLimit: 3,
  credentials: 'include',  // for cross-origin requests with cookies
  signal: abortController.signal
});

uploadFile(url, file, headers?, options?)

Upload a File or Blob with retry.

const response = await uploadFile(url, fileBlob, headers, { timeout: 60000 });

get(url, headers?, options?)

GET request with retry.

delete(url, headers?, options?)

DELETE request with retry.

parseError(error)

Parse a ky error into a structured object with status, statusText, and data.

import { postJson, parseError } from '@nvdigitalsolutions/nvoos-http-client';

try {
  const response = await postJson(url, data, headers);
} catch (error) {
  const details = await parseError(error);
  console.error(`HTTP ${details.status}: ${details.message}`, details.data);
}

Defaults

| Setting | Default | |---------|---------| | Timeout | 30 seconds | | Retry limit | 3 attempts | | Retry status codes | 408, 413, 429, 500, 502, 503, 504 | | Retry methods | GET, POST, PUT, PATCH, DELETE | | Max backoff | 10 seconds |

TypeScript

Full TypeScript definitions are included:

import type { HttpClientOptions, RequestOptions, ParsedError } from '@nvdigitalsolutions/nvoos-http-client';

License

MIT — NV Digital Solutions