Due Date: Thursday, September 21st at 10:00am

Overview

In recitation on 9/21, we’ll cover Node.js and Express.js. We’ll also walk through some code that will ultimately be very close to the starter code for your assignment.

This prep will ask you to write a small amount of code in order to get your feet wet with the starter code and begin seeing how you’ll implement your concepts and routes. In order to receive credit for the prep, you must submit a link to your work showing a legitimate attempt (do not worry if you don’t have it working perfectly). Fork this repo.

The purpose of this prep is to allow you to gain some familiarity with Node.js and Express.js and give you a head start on reading through and understanding parts of the starter code that you’ll work with on your assignment.

Introduction to Node.js

Node.js is a server-side JavaScript runtime environment that is built for web development.

As you may have noticed, Node.js comes with lots of packages that we can use to build web apps more easily. In fact, when you run npm run docs:dev when developing your portfolio, you’re using the Node Package Manager.

Introduction to Express.js

Express.js is a popular Node.js backend web application framework, and we will use Express in the apps we build in 6.1040. The starter code we give you will do most of the Express setup, so you don’t need to memorize the nitty gritty details, but you should briefly read through main.ts. Take a look at routes.ts and notice how we’re importing the routes for Express to use. For a refresher on routes, parameters, HTTP requests, etc., we encourage you to check out this reading from 6.102.

Task

Following the instructions in the README, run the code. Play around with logging in and out, and notice how if you’re logged in, you can still log in again as another user before logging out! Your goal is to fix this bug. Namely, if the user is already logged in and then tries to log in again, an error should be thrown.

There is a TODO in websession.ts with a hint. You should only need to modify code in websession.ts.

Commit and push your code once you’re done. In the event you aren’t able to complete the exercise, still push what you have. The form will have an option to explain where you got stuck.

Submit this Google form when you’re done to show us your work!