Demonstrating authentication by verifying a token using Express route middleware.
- node, npm, express and mongoose
- Clone the repo
- Install dependencies:
npm install
- Change SECRET in
config.js
- Add your own MongoDB database to
config.js
- Start the server:
node server.js
- Create sample user by visiting:
http://localhost:3000/setup
Once everything is set up, we can begin to use our app by creating and verifying tokens.
Send a POST
request to http://localhost:3000/api/authenticate
.
You can also send the token as a URL parameter: http://localhost:3000/api/users?token=YOUR_TOKEN_HERE