Skip to main content

Class: Middleware

@sapphire/plugin-api.Middleware

since 1.0.0

Hierarchy

  • Piece

    Middleware

Constructors

constructor

new Middleware(context, options?)

Parameters

NameType
contextPieceContext
optionsMiddlewareOptions

Overrides

Piece.constructor

Defined in

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

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:21

Methods

run

Abstract run(request, response, route): unknown

The method to be overridden by other middlewares.

Parameters

NameTypeDescription
requestApiRequestThe client's request.
responseApiResponseThe server's response.
routenull | RouteThe route that matched this request, will be null if none matched.

Returns

unknown

Defined in

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