Skip to main content
Home

Built and signed on GitHub Actions

Core framework for composable fetch middlewares.

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
100%
Published
a month ago (0.1.0)

@qfetch/core

Core framework for composable fetch middlewares.

Overview

Provides TypeScript types and composition utilities for building middleware that wraps the native fetch API. Create reusable request/response processing logic through a clean middleware pattern.

Installation

npm install @qfetch/core

API

Types

  • FetchFunction - Compatible with native fetch API
  • MiddlewareExecutor - Function that wraps a fetch function with middleware logic
  • Middleware<T> - Factory for creating middleware executors with optional configuration

Composition

  • compose(...middlewares) - Right-to-left composition (functional style)
  • pipeline(...middlewares) - Left-to-right composition (pipeline style)

Usage

import { compose, pipeline, type Middleware } from '@qfetch/core';

// Create a simple middleware
const withLogger: Middleware = () => (next) => async (input, init) => {
  console.log('Request:', input);
  const response = await next(input, init);
  console.log('Response:', response.status);
  return response;
};

// Compose with other middlewares
const qfetch = compose(
  withLogger(),
  // other middlewares...
)(fetch);

// Or use pipeline for left-to-right execution
const qfetch2 = pipeline(
  withLogger(),
  // other middlewares...
)(fetch);
Built and signed on
GitHub Actions

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@qfetch/core

Import symbol

import * as core from "@qfetch/core";
or

Import directly with a jsr specifier

import * as core from "jsr:@qfetch/core";

Add Package

pnpm i jsr:@qfetch/core
or (using pnpm 10.8 or older)
pnpm dlx jsr add @qfetch/core

Import symbol

import * as core from "@qfetch/core";

Add Package

yarn add jsr:@qfetch/core
or (using Yarn 4.8 or older)
yarn dlx jsr add @qfetch/core

Import symbol

import * as core from "@qfetch/core";

Add Package

vlt install jsr:@qfetch/core

Import symbol

import * as core from "@qfetch/core";

Add Package

npx jsr add @qfetch/core

Import symbol

import * as core from "@qfetch/core";

Add Package

bunx jsr add @qfetch/core

Import symbol

import * as core from "@qfetch/core";