Using a package for sessions
Now that you understand how sessions work, it is time to replace the custom code with an off-the-shelf sessions package, such as the one provided by Express. Run the commands shown in Listing 13.19 in the part2app
folder to install the sessions package, the type description package for its API, and a package that stores sessions in a database using Sequelize. (There is a wide range of database options for the express-sessions package, described at https://github.com/expressjs/session).
Listing 13.19: Installing packages
npm install express-session@1.17.3
npm install connect-session-sequelize@7.1.7
npm install --save-dev @types/express-session@1.17.10
Listing 13.20 prepares the application to use the session package and the storage package.
Listing 13.20: Using the session package in the session_helpers.ts file in the src/server/sessions folder
import { Request } from "express";
//import { Session } from "./repository...