Skip to content

Authentication API utilising JSON Web Tokens to authenticate user having MongoDB as the database and NodeJS providing the backend

Notifications You must be signed in to change notification settings

TheDynamicPunk/Authentication-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Authentication-API

Authentication API utilizing JSON Web Tokens to authenticate user having MongoDB as the database and NodeJS providing the backend.

Running the API

You need to have npm installed in your system and a code editor (like VSCode)

  1. Open the command prompt and navigate to the project directory
  2. Run the following command in the terminal
npm install
  1. Create .env file and copy-paste the contents of the .env-sample file in it
  2. Create a database in Mlab and paste the link of your DB in front of DB_URL = in .env file
  3. Now assign any random value to TOKEN_SECRET upto 128 bits
  4. Now run the server by running the following command in terminal
npm start
  1. Simulate API calls using either Insomnia or Postman.

API Endpoints

Public Routes

  1. /api/user/login - POST
Body
{
	"email": "",
	"password": "",
	"date": ""
}

Date - parameter is optional

  1. /api/user/register - POST
Body
{
	"name": "",
	"email": "",
	"password": "",
	"date": ""
}

Date - parameter is optional

Private Route

/api/user/login - GET

Headers
{
	"auth-token": ""
}

auth-token paste the token value you get while logging in or registering

About

Authentication API utilising JSON Web Tokens to authenticate user having MongoDB as the database and NodeJS providing the backend

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published