Preparing for this chapter
In this chapter, I continue to use the webapp
project created in Chapter 4. To prepare for this chapter, replace the contents of the handler.ts
file in the src
folder with the code shown in Listing 5.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 to get help if you have problems running the examples.
Listing 5.1: Replacing the contents of the handler.ts file in the src folder
import { IncomingMessage, ServerResponse } from "http";
export const handler = async (req: IncomingMessage, resp: ServerResponse) => {
resp.end("Hello, World");
};
Replace the contents of the server.ts
file in the src
folder with the code shown in Listing 5.2.
Listing 5.2: Replacing the contents of the server.ts file in the src folder
import { createServer...