Skip to content

Logic issue in 22th problem example #3

Description

@bacher

I found the logical issue in 22th problem

Middleware type don't consider promises as output.

If we add one more middleware after middleware with async function we see that req become Promise:

image

Solution: add Promise<> variant to return value:

use<NewTOutput extends TOutput>(
    middleware: Middleware<TOutput, NewTOutput | Promise<NewTOutput>>
  ): DynamicMiddleware<TInput, NewTOutput>  {
    this.middleware.push(middleware);
    ...

+ | Promise<NewTOutput> solves the problem

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions