Skip to content
GitHub

HandlerInspection

interface in meocord/testing Since 4.1.0

interface HandlerInspection

What runs for one handler, and the metadata declared on it, as inspectHandler reports it.

Members

controller

readonly controller: new (...args: any[]) => unknown

The controller class declaring the handler.

methodName

readonly methodName: string

The handler method's name.

guards

readonly guards: readonly InspectedGuard[]

The guards that run before the handler, in order: global guards, class guards, then method guards.

interceptors

readonly interceptors: readonly InspectedInterceptor[]

The interceptors around the handler, outermost first: global, class, then method interceptors.

filters

readonly filters: readonly InspectedFilter[]

The exception filters for the handler, in the order they are tried: the method's, then the controller's, then global ones.

cooldowns

readonly cooldowns: readonly InspectedCooldown[]

The handler's cooldowns, the controller's first, with their defaults filled in.

pattern

readonly pattern: string | undefined

The @MessageHandler pattern, or undefined for a listener and for any other kind of handler.

inheritedRoutes Since 4.2.0

readonly inheritedRoutes: readonly string[]

The routes the handler answers because a class its controller extends declares them, such as slash "ping": those its own class doesn't declare for it. Empty for a handler that declares all it answers. A test reads it; toEqual doesn't compare it, so an assertion on the other fields holds either way.

observers

readonly observers: readonly (new (...args: any[]) => DispatchObserver)[]

The app's observers, in the order they are told about the call; empty without an app.

get

get<T>(metadata: MetadataDecorator<T>): T | undefined
get<T = unknown>(key: string | symbol): T | undefined

Reads a metadata value as ExecutionContext.get does: the method's value, else the controller's.

Parameters

NameTypeDescription
metadataMetadataDecorator<T>

A decorator made by createMetadata.

Returns

T | undefined

The value, or undefined when neither declares one.

Parameters

NameTypeDescription
keystring | symbol

The key SetMetadata stored the value under.

Returns

T | undefined

The value, or undefined when neither declares one.

getAll

getAll<T>(metadata: MetadataDecorator<T>): T[]
getAll<T = unknown>(key: string | symbol): T[]

Reads every declared value as ExecutionContext.getAll does, method first, then controller.

Parameters

NameTypeDescription
metadataMetadataDecorator<T>

A decorator made by createMetadata.

Returns

T[]

The declared values; empty when none is declared.

Parameters

NameTypeDescription
keystring | symbol

The key SetMetadata stored the values under.

Returns

T[]

The declared values; empty when none is declared.