Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Type aliases

IRequestMiddleware

IRequestMiddleware<R, T>: (request: express.Request) => Promise<Either<IResponse<R>, T>>

Interface for implementing a request middleware.

A RequestMiddleware is just a function that validates a request or extracts some object out of it. The middleware returns a promise that will resolve to a value that gets passed to the handler. In case the validation fails, the middleware rejects the promise (the value of the error is discarded). In this case the processing of the following middlewares will not happen. Finally, when called, the middleware has full access to the request and the response objects. Access to the response object is particulary useful for returning error messages when the validation fails.

Type parameters

  • R

  • T

Type declaration

    • (request: express.Request): Promise<Either<IResponse<R>, T>>
    • Parameters

      • request: express.Request

      Returns Promise<Either<IResponse<R>, T>>

RequestHandler

RequestHandler<R>: (request: express.Request) => Promise<IResponse<R>>

Type parameters

  • R

Type declaration

    • (request: express.Request): Promise<IResponse<R>>
    • Parameters

      • request: express.Request

      Returns Promise<IResponse<R>>

Functions

withRequestMiddlewares

wrapRequestHandler

  • wrapRequestHandler<R>(handler: RequestHandler<R>): express.RequestHandler
  • Transforms a typesafe RequestHandler into an Express Request Handler.

    Failed promises will be mapped to 500 errors handled by ResponseErrorGeneric.

    Type parameters

    • R

    Parameters

    Returns express.RequestHandler

Legend

  • Variable
  • Function
  • Function with type parameter
  • Type alias
  • Type alias with type parameter
  • Interface
  • Interface with type parameter
  • Enumeration
  • Class with type parameter

Generated using TypeDoc