Authentication API utilizing JSON Web Tokens to authenticate user having MongoDB as the database and NodeJS providing the backend.
You need to have npm installed in your system and a code editor (like VSCode)
- Open the command prompt and navigate to the project directory
- Run the following command in the terminal
npm install- Create .env file and copy-paste the contents of the .env-sample file in it
- Create a database in Mlab and paste the link of your DB in front of
DB_URL =in .env file - Now assign any random value to
TOKEN_SECRETupto 128 bits - Now run the server by running the following command in terminal
npm start/api/user/login- POST
{
"email": "",
"password": "",
"date": ""
}Date - parameter is optional
/api/user/register- POST
{
"name": "",
"email": "",
"password": "",
"date": ""
}Date - parameter is optional
/api/user/login - GET
{
"auth-token": ""
}
auth-tokenpaste the token value you get while logging in or registering