Skip to main content

Class: abstract Middleware<Options>

Since

1.0.0

Extends

  • Piece<Options, "middlewares">

Type Parameters

Type ParameterDefault type
Options extends OptionsOptions

Constructors

new Middleware()

new Middleware<Options>(context: LoaderContext, options: Options): Middleware<Options>

Parameters

ParameterType
contextLoaderContext
optionsOptions

Returns

Middleware<Options>

Overrides

Piece<Options, 'middlewares'>.constructor

Defined in

projects/plugins/packages/api/src/lib/structures/Middleware.ts:22

Properties

position

readonly position: number

The position the middleware has. The MiddlewareStore will run all middlewares with lower position than this one.

The built-in middlewares follow the following positions:

  • headers: 10
  • body: 20
  • cookies: 30
  • auth: 40

Defined in

projects/plugins/packages/api/src/lib/structures/Middleware.ts:20

Methods

run()

abstract run(request: ApiRequest, response: Response): unknown

The method to be overridden by other middlewares.

Parameters

ParameterTypeDescription
requestApiRequestThe client's request.
responseResponseThe server's response.

Returns

unknown

Defined in

projects/plugins/packages/api/src/lib/structures/Middleware.ts:33