compose-middleware

  • Version 5.0.1
  • Published
  • 32.5 kB
  • 3 dependencies
  • MIT license

Install

npm i compose-middleware
yarn add compose-middleware
pnpm add compose-middleware

Overview

Compose an array of middleware into a single function for use in Express, Connect, router, etc.

Index

Functions

function compose

compose: <T, U, V = void>(
...handlers: Handler<T, U, V>[]
) => RequestHandler<T, U, V>;
  • Compose an array of middleware handlers into a single handler.

function errors

errors: <T, U, V = void>(
...handlers: Handler<T, U, V>[]
) => ErrorHandler<T, U, V>;
  • Wrap middleware handlers.

Type Aliases

type ErrorHandler

type ErrorHandler<T, U, V = void> = (err: Error, req: T, res: U, next: Next<V>) => V;

    type Handler

    type Handler<T, U, V = void> =
    | Middleware<T, U, V>
    | flatten.NestedArray<Middleware<T, U, V>>;

      type Middleware

      type Middleware<T, U, V = void> = RequestHandler<T, U, V> | ErrorHandler<T, U, V>;

        type Next

        type Next<T = void> = (err?: Error | null) => T;

          type RequestHandler

          type RequestHandler<T, U, V = void> = (req: T, res: U, next: Next<V>) => V;

            Package Files (1)

            Dependencies (3)

            Dev Dependencies (8)

            Peer Dependencies (0)

            No peer dependencies.

            Badge

            To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

            You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/compose-middleware.

            • Markdown
              [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/compose-middleware)
            • HTML
              <a href="https://www.jsdocs.io/package/compose-middleware"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>