Implementing Routes

As part of the Express server configuration, the ./routes.js file shown in Listing 26.3 is loaded. This file implements the routes necessary to support signup, login, editing, and user deletion. This code also implements static routes that support loading the static files.

Notice that req.session is used frequently throughout the routes code. This is the session created when expressSession() middleware was added in the previous section. Notice that the following code is called to clean up the existing session data when the user logs out or is deleted:

req.session.destroy(function(){});

The code attaches text strings to the session.msg variable so that they can be added to the template. (This ...

Get Node.js, MongoDB, and AngularJS Web Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.