Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Middleware

Generic async middleware, handles a stack (or pipeline) of functions that to pass along and possibly modify state for a final piece of functionality.

Similar to Express middleware, every middleware piece receives the same API signature of state, next, and done. Each piece can either continue the chain (by calling next) or interrupt the chain (by calling done). If all middleware continues, a complete function is called to handle the final state.

Middleware may wrap the done function to allow executing code in the second half of the process (after complete has been executed).

Different kinds of middleware may receive different information in the state object. For more details, see the API for each type of middleware.

Hierarchy

  • Middleware

Index

Constructors

Properties

Methods

Constructors

constructor

Properties

stack

stack: IPiece[] = []

Contains middleware "pieces" (callbacks) to execute

type

type: string

Methods

execute

  • Execute middleware in order, following by chained completion handlers. State to process can be an object with state properties or existing state.

    Parameters

    Returns Promise<State>

register

  • register(piece: IPiece): void

Generated using TypeDoc