Reading Class 07 - meron-401n14/seattle-javascript-401n14 GitHub Wiki

Express

Express is a dependency used to start up a server application We have to use package.json file to define our dependencies. In order to start up your server.js file express needs to be defined such as: var express = require('express'); var app = express(); var port = process.env.PORT || 8080;

Express Router

It is a mini express application that allows you to connect different routes on your page. Route Middleware router.use() Route middleware in Express is a way to do something before a request is processed such as: This could be things like checking if a user is authenticated, logging data for analytics, or anything else we'd like to do before we actually spit out information to our user.

ExpressJS - Middleware

Middleware functions are functions that have access to the request object (req), the response object (res), and the next middleware function in the application’s request-response cycle. These functions are used to modify req and res objects for tasks like parsing request bodies, adding response headers, etc.

Third Party Middleware

body-parser: This is used to parse the body of requests which have payloads attached to them. cookie-parser: It parses Cookie header and populate req.cookies with an object keyed by cookie names. express-session: It creates a session middleware with the given options.