Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logic issue in 22th problem example #3

Open
bacher opened this issue Dec 14, 2022 · 0 comments
Open

Logic issue in 22th problem example #3

bacher opened this issue Dec 14, 2022 · 0 comments

Comments

@bacher
Copy link

bacher commented Dec 14, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant