Options
All
  • Public
  • Public/Protected
  • All
Menu

The central manager that connects all the necessary handlers to go from an incoming request to an executed operation.

Hierarchy

Index

Constructors

constructor

Properties

Private Readonly authorizer

authorizer: Authorizer

Private Readonly credentialsExtractor

credentialsExtractor: CredentialsExtractor

Private Readonly logger

logger: Logger = ...

Private Readonly operationHandler

operationHandler: OperationHandler

Private Readonly permissionsExtractor

permissionsExtractor: PermissionsExtractor

Private Readonly requestParser

requestParser: RequestParser

Private Readonly responseWriter

responseWriter: ResponseWriter

Methods

canHandle

  • Checks if the incoming request can be handled. The check is very non-restrictive and will usually be true. It is based on whether the incoming request can be parsed to an operation.

    Parameters

    • input: HttpHandlerInput

      Incoming request and response. Only the request will be used.

    Returns Promise<void>

    A promise resolving if this request can be handled, otherwise rejecting with an Error.

handle

  • Handles the incoming request and writes out the response. This includes the following steps:

    • Parsing the request to an Operation.
    • Extracting credentials from the request.
    • Extracting the required permissions.
    • Validating if this operation is allowed.
    • Executing the operation.
    • Writing out the response.

    Parameters

    Returns Promise<void>

    A promise resolving when the handling is finished.

handleSafe

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

    Parameters

    Returns Promise<void>

    A promise resolving if the input can be handled, rejecting with an Error if not. Return value depends on the given type.

Private runHandlers

  • Runs all handlers except writing the output to the response. This because any errors thrown here have an impact on the response.

    Parameters

    • request: Guarded<IncomingMessage>

      Incoming request.

    Returns Promise<ResponseDescription>

    A promise resolving to the generated Operation.