Skip to content

thedeveloperyug/userAuthentication_Backend

Repository files navigation

Steps to run the project

To run the project, follow these steps:

Clone the repository Install dependencies:

npm install

Connect MongoDB by pasting your URL:

Mongo URL

(Don't forget to add your current IP Address in MongoDB)
Usage:
To run the project, use the following command:

npm run dev

APIs Available The following APIs are available:

../api/users ../api/contacts
You can access the APIs using the following format: http://localhost:5001/api/


Register a New User
To register a new user, use the following API:
API: ../api/users/register
Method: POST
JSON Data:
{ "username":"test", "email" : "[email protected]", "password":"test123" }

User Login
To log in as a user, use the following API:
API: ../api/users/login
Method: POST
JSON Data:
{ "email" : "[email protected]", "password":"test123" }
Output: You'll get an Access token copy that token.


Getting Users Data
To get users' data, use the following API:
API: ../api/contacts/
Method: GET
Send request with token that you copied:
Thunder Client -> Auth -> Bearer -> (paste the token)


Creating Users Data
To create a new user data, use the following API:
API: ../api/contacts/
Method: POST
Send request with JSON and token that you copied:
Thunder Client -> Auth -> Bearer -> (paste the token)
JSON Data:
{ "name":"testdata", "email" : "[email protected]", "phone":"6734567890" }


Updating Users Data
To update a user data, use the following API:
API: ../api/contacts/_id
Replace _id with the unique_id of the user you want to update.
Method: PUT
Send request with JSON and token that you copied:
Thunder Client -> Auth -> Bearer -> (paste the token)
JSON Data:
{ "username":"testdataupdated", "email" : "[email protected]", "phone":"9034567890" }


Deleting Users Data
To delete a user data, use the following API:
API: ../api/contacts/_id
Replace _id with the unique_id of the user you want to delete.
Method: DELETE
Send request with token that you copied:
Thunder Client -> Auth -> Bearer -> (paste the token)

About

CRUD Operations using Node.js, REST API

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published