Skip to content

xavicorral/Jwt-Api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

User authenticator API built in node for demonstration purposes.

The logged user session is kept alive with the use of a JWT token

To set it up, you will need to have previoulsy installed in your system:

Instructions

  • Clone the repo
git clone [email protected]:xavicorral/Jwt-Api.git
  • Install node dependencies
npm install
  • Start docker containers with mongodb and mongoexpress
docker-compose up
  • Start the server:
node src/server.js

That's it! To check if the server is up and running, try accessing http://localhost:5000/api

If you want to test it through command line:

  • Register
curl -d "[email protected]&password=123456" -H "Content-Type: application/x-www-form-urlencoded" -X POST http://localhost:5000/api/register
  • Login
curl -d "[email protected]&password=123456" -H "Content-Type: application/x-www-form-urlencoded" -X POST http://localhost:5000/api/login
  • Private area (gather the token received in the previous step)
curl -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVjOWZmNGFkNmJkOTQyNzZiMzIyOGM5YSIsImVtYWlsIjoiYW5uYW1pdmlzQGdtYWlsLmNvbSIsImlhdCI6MTU1Mzk4Njc1MSwiZXhwIjoxNTUzOTg2OTUxfQ.dQgdTPStrwdeQBJ5MwoXDF7NSfzuJI0tsBTLOfwaIr4"  -X GET http://localhost:5000/api/private-area

About

User authorization API built in Node with JWT

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published