03 - Changes to app.js
In this module, we'll make changes to app.js
to allow us to create the authenticated routes.
app.js
In the app.js
file on the server side, make the following changes as noted by the comments:
Analysis
In this file, we changed the app.js
to do the following: 1. We imported the authtestcontroller
file for access to the endpoints. We will create this file in the next module. Until then, your server might throw an error, as it's looking for a file that doesn't exist. 2. We imported the validate-session
middleware, which will check to see if the incoming request has a token. 3. Anything beneath the validate-session
will require a token to access, thus becoming protected. Anything above it will not require a token, remaining unprotected. Therefore, the test
and user
routes are not protected, while the authtest
route is protected.
Last updated