Skip to content

colored-strategies/jwt-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSON Web Tokens API

This is an authentication, token encode & decode API that uses JWT technology and MongoDB data source.

Running the API

API serves over http://localhost:3000/ by default. Following commands starts up the server.
npm run dev OR yarn dev

API Configuration

This API uses two environment variables. MONGO_URI used as a MongoDB connection string. JWT_SECRET used as a secret key signature.

Add MONGO_URI & JWT_SECRET variables to your .env file by updating with your own keys.

MONGO_URI="mongodb://username:password@localhost/testDB?retryWrites=true&w=majority"
JWT_SECRET="abc123"

API Routing

API serves over POST and DELETE methods. Additional routing may be added as desired.

POST         /user/signUp        Add user data to data source   
POST         /user/authenticate  Generate token for given authentication information   
POST         /user/verify        Confirm given token is valid   
POST         /user/getUser       Decode given token and get user data    
DELETE       /user/delete        Delete the data source content (use with caution!) 

Example Request

  • POST /user/signUp
  • Name:Ultimo   
    Surname:Magnefiso   
    Gender:Female   
    DateOfBirth:01/01/1990   
    Username:aa   
    Password:bb   
    
  • POST /user/authenticate
  • username:aa   
    password:bb   
    
  • POST /user/verify
  • token:addsadasd.hfghfghfg.sfdsdfsd   
    
  • POST /user/getUser
  • token:addsadasd.hfghfghfg.sfdsdfsd   
    

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published