Preparing for this chapter
In this chapter, I will continue to use the webapp
project created in Chapter 4 and modified in Chapter 3. To prepare for this chapter, replace the contents of the server.ts
file in the src
folder with the code shown in Listing 6.1.
Tip
You can download the example project for this chapter – and for all the other chapters in this book – from https://github.com/PacktPublishing/Mastering-Node.js-Web-Development. See Chapter 1 for how to get help if you have problems running the examples.
Listing 6.1: Replacing the contents of the server.Ts file in the src folder
import { createServer } from "http";
import express, {Express } from "express";
import { basicHandler } from "./handler";
const port = 5000;
const expressApp: Express = express();
expressApp.get("/favicon.ico", (req, resp) => {
resp.statusCode = 404;
resp.end();
});
expressApp.get("*", basicHandler...