A stack storing middleware. It can be resolved into a handler. It supports 2 approaches for adding middleware:

  1. Adding middleware to specific step with add(). The order of middleware added into same step is determined by order of adding them. If one middleware needs to be executed at the front of the step or at the end of step, set priority options to high or low.
  2. Adding middleware to location relative to known middleware with addRelativeTo(). This is useful when given middleware must be executed before or after specific middleware(toMiddleware). You can add a middleware relatively to another middleware which also added relatively. But eventually, this relative middleware chain must be 'anchored' by a middleware that added using add() API with absolute step and priority. This mothod will throw if specified toMiddleware is not found.
interface MiddlewareStack<Input, Output> {
    applyToStack: ((stack) => void);
    add(middleware, options?): void;
    add(middleware, options): void;
    add(middleware, options): void;
    add(middleware, options): void;
    add(middleware, options): void;
    addRelativeTo(middleware, options): void;
    clone(): MiddlewareStack<Input, Output>;
    concat<InputType, OutputType>(from): MiddlewareStack<InputType, OutputType>;
    identify(): string[];
    remove(toRemove): boolean;
    removeByTag(toRemove): boolean;
    resolve<InputType, OutputType>(handler, context): InitializeHandler<InputType, OutputType>;
    use(pluggable): void;
}

Type Parameters

  • Input extends object

  • Output extends object

Hierarchy (view full)

Properties

applyToStack: ((stack) => void)

A function that mutate the passed in middleware stack. Functions implementing this interface can add, remove, modify existing middleware stack from clients or commands

Type declaration

    • (stack): void
    • A function that mutate the passed in middleware stack. Functions implementing this interface can add, remove, modify existing middleware stack from clients or commands

      Parameters

      Returns void

Methods

  • Returns a list of the current order of middleware in the stack. This does not execute the middleware functions, nor does it provide a reference to the stack itself.

    Returns string[]

  • Removes middleware from the stack.

    If a string is provided, it will be treated as middleware name. If a middleware is inserted with the given name, it will be removed.

    If a middleware class is provided, all usages thereof will be removed.

    Parameters

    Returns boolean

  • Removes middleware that contains given tag

    Multiple middleware will potentially be removed

    Parameters

    • toRemove: string

    Returns boolean

  • Apply a customization function to mutate the middleware stack, often used for customizations that requires mutating multiple middleware.

    Parameters

    Returns void