Class BaseRouterHandler<T>Abstract

Checks if a given method and path are satisfied and allows its handler to be executed if so.

Implementations of this class should call canHandleInput in their canHandle call with the correct parameters.

canHandleInput expects a ResourceIdentifier to indicate it expects the target to have been validated already.

Type Parameters

Hierarchy

Constructors

Properties

allMethods: boolean
allowedMethods: string[]
allowedPathNamesRegEx: RegExp[]
baseUrlLength: number
handler: T

Methods

  • Checks if the input can be handled by this class. If it cannot handle the input, rejects with an error explaining why.

    Parameters

    Returns Promise<void>

    A promise resolving if the input can be handled, rejecting with an Error if not.

  • Helper function that first runs canHandle followed by handle. Throws the error of canHandle if the data cannot be handled, or returns the result of handle otherwise.

    Parameters

    Returns Promise<Awaited<ReturnType<T["handle"]>>>

    A promise resolving if the input can be handled, rejecting with an Error if not.