PassportJS + JWT + ServerJs
NOTE: requires MongoDB up and running
# Clone repo
❯ git clone https://github.com/frenchbread/server.js-auth-example.git && cd server.js-auth-example
# Install dependencies
❯ yarn install
# or
❯ npm install
# Start server
❯ node server.js
❯ curl -H "Content-Type: application/json" -X POST -d '{"email":"some@mail.com","password":"somepassword"}' http://localhost:3030/register
# Server reply
{"ok":true,"message":"Successfully created new user."}
❯ curl -H "Content-Type: application/json" -X POST -d '{"email":"some@mail.com","password":"somepassword"}' http://localhost:3030/login
# Server reply
{"ok":true,"data":{"user":{"_id":"5a0129ec1cc973ec2e92b985","email":"some@mail.com"},"token":"<received_jwt_token>"}}
❯ curl -H 'Authorization: JWT <received_jwt_token>' -X GET http://127.0.0.1:3030/verify
# Server reply
{"ok":true,"user":{"_id":"5a0129ec1cc973ec2e92b985","email":"some@mail.com","__v":0}}