In this chapter, we're going to use a piece of middleware called socket.io to create a simple live chat for our site. But just like with other sections, we'll start off by preparing our route and the associated pages that will go with it. As long as there's no complex functionality, it's just a matter of creating the route file, the html page and then creating the appropriate links and references.
- [Voicever] In this chapter, we're going to use…a piece of middleware called Socket.IO…to create a simple live chat for our site.…But just like with other sections,…we'll start off by preparing our route…and the associated pages that will go with it.…Now this is gonna be pretty simple and somewhat of a review,…so let's get going.…So first, I'm gonna go into my app.js file,…and I'm going to add the link to the additional route…which will be chat route.…
And then, I'm not gonna save yet,…I'm going to create that route right here.…It's gonna be pretty similar to what we did in feedback.js,…so I'll make a copy of that one,…and I'll call it "chat" of course.…So of course chat is going to have "chat"…instead of "feeback" here for the get and the page ID…as well as the page title.…And there's not gonna be any additional…functionality in this route.…We're gonna take care of everything in app.js,…so I'm gonna save that,…and I need to create the chat view…that I'm referring to right here in this Render command.…
So again, I'm going to take the feedback.ejs file…
In this course, Ray Villalobos walks through the process of creating full-featured websites with these technologies. First, find out how to install each package and leverage Node.js features from within Express. Then learn how to build a basic application with templating engines like EJS; create more flexible, modular code with includes and conditional statements; build APIs to manage HTTP requests to add and delete content dynamically; and configure more complex routing. Along the way, Ray implements features like customer feedback forms and real-time live chat, so you can see exactly what Node.js and Express are capable of.
- Handling HTTP requests with Node.js and Express
- Creating and modularizing routes
- Using templates
- Building flexible views
- Creating an API route
- Dealing with POST and DELETE requests
- Creating live chat features with Socket.IO