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 [email protected]
npm install [email protected]
npm install --save-dev @types/[email protected]
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...