This course has been updated! We now recommend you take the AWS for Front-End Engineers (ft. S3, Cloudfront & Route 53) course.
Transcript from the "Serving HTTP Requests with Express" Lesson
>> Kevin Whinnery: The first part that we'll start to break down in our application stack is one of the most important components that we have in the stack, which is the Express Web server. It handles incoming HTTP requests and renders HTTP responses with HTML and JSON. It's kind of a core component of this and any other NODE.JS web application.
[00:00:28] It's very similar in style to, say Sinatra, if you've worked with that framework in the Ruby world. Or maybe Nancy from the C# world, or any number of other HTTP micro frameworks out there, in that it is very minimal. And it's also by far the most popular HTTP request handling library out there.
[00:01:18] Anything you want Express to do, you have to install as additional middleware or some other add-on to the software. So there's good things and bad things about this. The good thing is that you never end up with more bloat in your application than you absolutely require. Because you're consciously choosing every single piece of software that's executed when you're handling an HTTP request.
[00:01:47] The downside is that there are no intelligent defaults. So if you want to do something like, I don't know parse incoming post requests from a client, you need to install an extra piece of middleware to do that. Which we have in our our sample application. So there's good things and bad things about that design.
[00:02:08] The reason why I still like it very much today is because it's not magical. It's very easy for me to reason about what this piece of software is actually doing. And the reason for that is it's all based on a middleware stack. Before we go any any further, does anybody know what this picture is a reference to, by any chance?
[00:02:28] No? All right, so what you all need to do today when you go home is fire up your Kindle and download Ready Player One. It's the name of the name of the book. And this is the stacks, which is a vertical trailer home, which is a trailer park which is featured in Ready Player One.
[00:03:41] And we'll see how we can figure that here in a second. We'll also have some specific routes in our applications. So we'll wanna handle specific URLs with specific logic, for maybe getting a to-do item out of our database or executing other logic when a certain path is requested within the web application.
[00:04:03] And then if the global middleware and the application routes are unable to process the request. Or, God forbid, an error happens during the execution of those middleware, we can have other middleware that's lower down in our stack that will catch errors like a 404 not found. Like, if we don't have a handler to handle a certain kind of request.