To create the REST API for the course management app, we need to start by creating the verification token, which will help us authorize a user every time they request the client-side. The token will get sent to the server as an authorization header, and the server will then process the token and verify if it’s a valid one. If the token sent to the server is verified as correct, the API will grant the request. If not, an error will get returned.

Setting up the token verification

To set up the token verification middleware, we need to create a new file called verifyToken.js in the middleware folder of our node.js application. We then proceed to type the code below inside our file:

Get hands-on with 1200+ tech skills courses.