advanced-patterns-workshop
advanced-patterns-workshop copied to clipboard
Logic issue in 22th problem example
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:

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