In this video, explore the basics of middleware in Express with examples of application-level middleware in the code. Then go over the differences in between application- and routing-level middleware.
- [Instructor] What is middleware?…In the context of our Node and Express server,…how would it be used?…Middleware are simply functions…that have access to the request…and response object in our Express application…and can run their code there.…It can make changes to the request and response objects,…can end them, can call…another function in the stack using next,…a function we've already used.…In a way, we've been creating our own application middleware…which basically means we add our own code…to do anything before we send a response back.…
But let's push further and do some more.…We'll do an example that routes with middleware…in one of the endpoints.…So let's get to it.…So get back to index.js,…and the first thing I want you to do…is click on line 22 here and just return.…So let's leave some space here.…So basically everything,…and I'm going to add a note here…so you can basically understand what's happening here.…So everything above is middleware.…
So all the code that we are doing…just before we actually send response back,…
- Creating a basic data endpoint
- Routing with Express
- Adding a static route for file serving
- Basic middleware with Express
- Built-in middleware and error-handling middleware
- Debugging in an Express application
- Security best practices with Express
Skill Level Beginner
1. Setting Up Express
2. Getting Started
3. Routing with Express
4. Middleware with Express
5. Advanced Topics in Express
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.