Step 4

Let's explore the routes and the logic to handle client requests.

Open index.js. Notice the following routes:

app.get("/", (req, res) => {
  // Homepage- Render login form  
});

app.post("/login", (req, res) => {
  // check credential then redirect to dashboard
});

app.get("/dashboard", (req, res) => {
  // Render dashboard 
});

app.post("/logout", (req, res) => {
  // Log user out then redirect to homepage
});

app.get("/register", (req, res) => {
  // Render registeration form
});

app.post("/register", (req, res) => {
  // Register the user then redirect to homepage
});

I've replaced the implementation of each route handler with a comment to briefly describe its job.

We will focus on the user registration process first.