Skip to content

Rajneesh0021/Bytive_assignment_stretch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bytive_assignment_stretch

check Deployed Full-Stack web Application :- Home

Bytive Backend Documentation

Welcome to the backend documentation for the Bytive application.

-check swagger_documentation for better experience

Table of Contents

Getting Started

  1. Clone the repository:

    git clone https://github.com/Uselessme21/Bytive_assignment_stretch.git
    cd your-repository
  2. Install Dependencies:

    npm install
  3. Set Environment Variables:

    Create a .env file in the root of your project and add the necessary environment variables.

  4. Start the Server:

    npm start

    This command will start the server.

  5. Access the API:

    Open your browser or a tool like Postman and access the API at the specified port (e.g., http://localhost:3000).

Authentication

Authentication is required for accessing private routes. The authentication process involves obtaining a JSON Web Token (JWT) by logging in. This token must be included in the headers of requests to private APIs.

Obtaining a JWT

To obtain a JWT, make a POST request to the /user/login endpoint with valid credentials.

POST /api/user/login or /api/user/register
Content-Type: application/json

{
  "email": "[email protected]",
  "password": "password123"
}

If the login is successful, the response will include a JWT token.

{
  "message": "Login successful",
  "token": "your-jwt-token",
  "profile": "user-id"
}

Using the JWT

Include the obtained JWT in the headers of requests to private routes. The header key should be Authorization, and the value should be Bearer your-jwt-token.

GET /api/user/private/route
Authorization: your-jwt-token

API Documentation

This document provides information about the API endpoints and their usage.

Endpoints

Get List of Profiles

  • Endpoint: /api/getusers
  • Method: GET
  • Description: Fetches a list of user profiles.
  • Privacy: Public

Search Profiles

  • Endpoint: /api/searchusers
  • Method: GET
  • Description: Searches user profiles based on provided parameters.
  • Privacy: Public

Update User Profile

  • Endpoint: /api/updateusers
  • Method: PUT
  • Description: Updates the user profile.
  • Privacy: Public

Register User

  • Endpoint: /api/user/register
  • Method: POST
  • Description: Registers a new user.
  • Privacy: Public

User Login

  • Endpoint: /api/user/login
  • Method: POST
  • Description: Logs in an existing user.
  • Privacy: Public

Edit User Profile

  • Endpoint: /api/user/editprofile/:userId
  • Method: PUT
  • Description: Edits the user profile.
  • Privacy: Private

Get User Profile

  • Endpoint: /api/user/userprofile/:userId
  • Method: GET
  • Description: Fetches the profile of a specific user.
  • Privacy: Private

Delete User Profile

  • Endpoint: /api/user/deleteprofile/:userId
  • Method: DELETE
  • Description: Deletes the user account.
  • Privacy: Private

User Logout

  • Endpoint: /api/user/logout
  • Method: GET
  • Description: Logs out the user.
  • Privacy: Private