Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

Usage

import * as middleware from "https://raw.githubusercontent.com/worker-tools/middleware/master/context.ts";

§Classes

EffectsList

§Functions

combine

Type-enforcing left-to-right function composition function. The first parameter can be a function of any arity, but the remaining parameters must be unary functions. The return type of one function must be compatible with the argument of next function in the argument list (i.e. types flow from left-to-right)

createMiddleware

A helper function to create user-defined middleware.

executeEffects deprecated
withMiddleware deprecated

Takes a handler function of the form (x: Request, ctx: Context) => Awaitable<Response> and applies middleware to it.

§Interfaces

Context
ExtendableEvent

Extends the lifetime of the install and activate events dispatched on the global scope as part of the service worker lifecycle. This ensures that any functional events (like FetchEvent) are not dispatched until it upgrades database schemas and deletes the outdated cache entries.

ExtendableEventInit
FetchEvent

This is the event type for fetch events dispatched on the service worker global scope. It contains information about the fetch, including the request and how the receiver will treat the response. It provides the event.respondWith() method, which allows us to provide a response to this fetch.

FetchEventInit
URLPatternComponentResult
URLPatternInit
URLPatternResult

§Type Aliases

ContextOf

Helper type to get the context type of a given middleware function.

ErrorContext deprecated
ErrorHandler deprecated
Handler deprecated
Middleware deprecated
Rec

Any record of unknown values

ResponseEffect
URLPatternInput