Skip to main content

Class: ApplicationMiddleware

An Application Middleware.

AppMiddleware

Constructors

new ApplicationMiddleware()

new ApplicationMiddleware(): ApplicationMiddleware

Returns

ApplicationMiddleware

Methods

getApplicationMiddleware()

getApplicationMiddleware(): object

Gets the Middleware's Details.

Returns

object

handler

handler: MiddlewareHandler

middleware

middleware: undefined | string

runsOnAllRoutes

runsOnAllRoutes: boolean

Defined in

types/registry/Middlewares/AppMiddlewareType.ts:62


runOnAllRoutes()

runOnAllRoutes(active): this

Determine if this middleware is a globally running middleware across your application, or local to any route that specifically uses it.

Parameters

active: boolean

Returns

this

Default

false // Updates to true if setMiddlewareName is unset.

Example

this.runOnAllRoutes(false)

Defined in

types/registry/Middlewares/AppMiddlewareType.ts:52


setHandler()

setHandler(handler): this

Set the callback function for your middleware.

Parameters

handler: MiddlewareHandler

Returns

this

Default

// Blank Handler

Example

this.setHandler(this.run)

Defined in

types/registry/Middlewares/AppMiddlewareType.ts:39


setMiddlewareName()

setMiddlewareName(name): this

Set the name of your middleware, this is used to enable the middleware in certain routes.

Parameters

name: undefined | string

Returns

this

Default

undefined // If no name is set or is set to "", runsOnAllRoutes will default to true and make it a global middleware.

Example

this.setMiddlewareName('authorisationMiddleware')

Defined in

types/registry/Middlewares/AppMiddlewareType.ts:25