Lesson 7.1
The onion and the dispatcher
What middleware is, how next() advances the stack, and how a response can stop dispatch. Then you build the dispatcher that awaits every entry.
What you will build
- Define middleware as a function of (req, res, next) with three moves, and read the onion's in-phase and out-phase order.
- Explain why dispatch advances only when an entry calls next(), and how omitting next() stops downstream work.
- Build dispatch(stack, req, res) - index recursion, the double-next guard, downstream tracking, and Promise.try.