In this video, Emmanuel Henri demonstrates a basic example of cascading middleware and how it relates to your back-end environment.
- [Instructor] We'll get started with a full example…of cascading in this video, and finish it in the next…so if you do any test in your server in this…video, be aware that the code will be incomplete.…So some of it will work, some of It will not work…so wait until the very next video until you test it.…So let's get started on adding the proper code.…So the first thing I'm going to do is remove…the app.context.date here.…We're not going to use it, we're actually going to…create a date inside of a logger.…So let's remove that first, and then what we'll do…is refactor our response.…
So right now we're doing a try and catch,…we're not going to use that anymore…so we're just going to do a response and the way…I want you to refactor this one is remove…all this here, like so, and then the code…from 13 to 15 like so.…So you should only see ctx.response.body, and let's…also remove the await, and then ctx.userdata.…So that's only what you should see.…The next thing we're going to do is add a logger.…So we need a function that will log the time,…
- What's Koa?
- Similarities and differences between Koa and Express
- What's a Koa Context?
- Throwing errors with Context
- Using async with Koa
- Cascading middleware