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

reqforge

v0.15.0

Published

A lightweight, flexible HTTP client library with request interception, automatic retry, and logging capabilities, designed for modern web applications.

Downloads

1,939

Readme

ReqForge

A lightweight, flexible HTTP client library with request interception, automatic retry, and logging capabilities, designed for modern web applications.

Installation

npm install reqforge

Quick Start

const { request, interceptor } = require('reqforge');

// Add a request interceptor
const reqInterceptor = interceptor.createRequestInterceptor();
reqInterceptor.use((config) => {
  console.log('Request:', config.url);
  return config;
});

// Make a request
request.get('/users')
  .then(res => res.json())
  .then(data => console.log(data));

Examples

See the examples directory for more usage examples:

API Reference

Request Methods

The request module provides:

  • sendRequest(endpoint, data, options) - Generic request method
  • get(endpoint, options) - GET request
  • post(endpoint, data, options) - POST request
  • put(endpoint, data, options) - PUT request
  • del(endpoint, options) - DELETE request

Configuration

The config module provides:

  • getBaseURL() - Get the base URL for API requests
  • API_VERSION - Current API version
  • defaultConfig - Default configuration object
  • mergeConfig(customConfig) - Merge custom configuration with defaults

DebugLogger

The DebugLogger class provides:

  • log(message) - Log a message
  • info(message) - Log an info message
  • warn(message) - Log a warning message
  • error(message) - Log an error message
  • debug(message, data) - Log debug message with optional data (only when debug mode enabled)
  • enableDebug() - Enable debug mode

Authentication

The auth module provides:

  • login(username, password) - Login and store token
  • logout() - Logout and clear token
  • getToken() - Get current auth token
  • setToken(token) - Set auth token manually
  • isAuthenticated() - Check if authenticated

Error Handling

The errors module provides:

  • ReqForgeError - Base error class
  • NetworkError - Network request failures
  • TimeoutError - Request timeout errors
  • AuthError - Authentication failures
  • ValidationError - Validation errors
  • ErrorCodes - Error code constants
  • createErrorFromResponse(response) - Create error from HTTP response

Retry Mechanism

The retry module provides:

  • withRetry(fn, options) - Execute function with automatic retry
  • calculateBackoff(attempt, baseDelay, maxDelay) - Calculate exponential backoff delay

Options for withRetry:

  • maxRetries (default: 3) - Maximum number of retry attempts
  • delay (default: 1000) - Initial delay in milliseconds
  • backoff (default: 2) - Backoff multiplier
  • shouldRetry(error) - Function to determine if retry should occur

Interceptors

The interceptor module provides request and response interception:

  • createRequestInterceptor() - Create request interceptor manager
  • createResponseInterceptor() - Create response interceptor manager

InterceptorManager Methods

  • use(fulfilled, rejected) - Add interceptor handler
  • eject(id) - Remove interceptor handler
  • clear() - Clear all handlers
  • forEach(data) - Process data through all handlers

Caching

The cache module provides:

  • MemoryCache - In-memory cache with TTL support
    • get(key) - Get cached value
    • set(key, value, ttl) - Set cached value with optional TTL
    • has(key) - Check if key exists
    • delete(key) - Remove cached entry
    • clear() - Clear all entries
    • size() - Get cache size
  • createCacheKey(url, params) - Generate cache key from URL and params

Utilities

The utils module provides:

  • buildURL(baseURL, params) - Build URL with query parameters
  • serializeQuery(obj) - Serialize object to query string
  • parseQuery(queryString) - Parse query string to object
  • deepMerge(target, source) - Deep merge objects
  • isPlainObject(value) - Check if value is a plain object
  • delay(ms) - Delay execution

TypeScript Support

TypeScript type definitions are included. Import types:

import { request, config, Logger } from 'reqforge';

Testing

npm test

Changelog

See CHANGELOG.md for version history.

License

MIT