Skip to content

internship-pentatech-it-solutions/MARK_ARYEE_Nodejs_Contacts_Backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GNU nano 8.2 readme.md Modified

Project Setup

Prerequisites:

Node.js and npm installed A MongoDB database instance

Installation:

git clone https://github.com/your-username/your-project-name.git cd your-project-name

Install Dependencies: npm install

Set Up Environment Variables:

Create a .env file in the project root and add the following:

MONGO_URI=your_mongodb_connection_string JWT_SECRET=your_secret_key

Running the Application:

Start the Server: npm start

Register a User:

Create a POST request to the registration endpoint (register). Provide the details in the request body; username, email, and password. Send the request and you should receive a success response if registration is successful.

Login the User

Create a POST request to the login endpoint (login). Provide the registered user's email and password in the request body. Send the request and you should receive a JSON response containing a JWT token

Testing Logout Functionality in Postman

Understanding the Logout Process:

A logout endpoint typically:

  1. Invalidates the Session: This can involve removing session cookies or clearing s>
  2. Revokes the JWT Token: If using JWT-based authentication, the token can be black>

Testing Logout in Postman:

  1. Obtain a Valid JWT Token:

    • First, use Postman to log in to your application and obtain a valid JWT token.
    • Store this token securely.
  2. Create a Logout Request:

    • HTTP Method: POST
    • URL: The endpoint for logging out (/logout)
    • Headers:
      • Authorization: Bearer <the_jwt_token>
  3. Send the Request:

    • Execute the request in Postman.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published