Skip to content

Latest commit

 

History

History
52 lines (49 loc) · 1.27 KB

File metadata and controls

52 lines (49 loc) · 1.27 KB

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