Simple APIs for user authentication using JWT where you can send web requests to register, login or checkToken. Here I am using DI pattern to wire between different modules.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. some of the node.js modules used here bcrypt
jsonwebtoken
Node.js and npm.
node -v
Install all the modules then run the server in either dev or prod mode
npm install
And
npm run start
To register a new user you can issue a POST request:
curl -X POST -d '{"username": "joe", "password":"1234"}' http://localhost:3000/user/register -H "Content-Type: application/json"
To login issue a POST request you should receive a token back if successful like
curl -X POST -d '{"username": "joe", "password":"1234"}' http://localhost:3000/user/login -H "Content-Type: application/json"
Check if token is valid
curl -X GET -H "Accept: application/json" http://localhost:3000/user/checkToken\?token\=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImJzYnMiLCJleHAiOjE1OTI1NTA1NDQsImlhdCI6MTU5MjU0Njk0NH0.RTFWeuNJw6loxQUUio5KhC7u1ufyfkudbkg21eSUxsg