You can use Express to create as many routes as you'd like. In cases where you want to insert some functionality before the request, you can use Express middleware to handle custom routing.
- [Man] We can use Express … But sometimes we want to insert some functionality … and believe or not … you've already been using it. … on line 17 we say app use express dot static … and we are sending the client folder. … So what is within this app use? … Well this is middleware … We can add our own. … using the request … and the response objects … that are available to you in all middleware. … So let's say we wanted to create a logger … that logs every request. … We could do that as middleware. … I can console log the REQ dot method. … REQ dot URL. … So using the request object on every request, … I can add a little logger here. … Now in order for my middleware to continue on … I have to invoke this third argument … which is the next function. … So the next function we'll go ahead … eventually 'till we resolve a route. … So let's go ahead and save this … and I'll go ahead and open up the terminal … and node our server. … And now what you're going to see is … as I make a request for local host 3000 …
- Making HTTP requests
- Building web and file servers
- Installing packages with npm
- Managing and linking global packages
- Working with Express, the web server framework
- Handling POST and DELETE requests
- Creating WebSockets
- Testing and debugging Node.js code
Skill Level Advanced
Node.js: Real-Time Web with Socket.IOwith Emmanuel Henri1h 24m Intermediate
Work with VSCode1m 59s
1. The HTTP Module
3. Web Servers
5. Node.js Testing
6. Automation and Deployment
- 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.