check Deployed Full-Stack web Application :- Home
Welcome to the backend documentation for the Bytive application.
-check swagger_documentation for better experience
-
Clone the repository:
git clone https://github.com/Uselessme21/Bytive_assignment_stretch.git cd your-repository
-
Install Dependencies:
npm install
-
Set Environment Variables:
Create a
.env
file in the root of your project and add the necessary environment variables. -
Start the Server:
npm start
This command will start the server.
-
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 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.
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": "user@example.com",
"password": "password123"
}
If the login is successful, the response will include a JWT token.
{
"message": "Login successful",
"token": "your-jwt-token",
"profile": "user-id"
}
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
This document provides information about the API endpoints and their usage.
- Endpoint:
/api/getusers
- Method: GET
- Description: Fetches a list of user profiles.
- Privacy: Public
- Endpoint:
/api/searchusers
- Method: GET
- Description: Searches user profiles based on provided parameters.
- Privacy: Public
- Endpoint:
/api/updateusers
- Method: PUT
- Description: Updates the user profile.
- Privacy: Public
- Endpoint:
/api/user/register
- Method: POST
- Description: Registers a new user.
- Privacy: Public
- Endpoint:
/api/user/login
- Method: POST
- Description: Logs in an existing user.
- Privacy: Public
- Endpoint:
/api/user/editprofile/:userId
- Method: PUT
- Description: Edits the user profile.
- Privacy: Private
- Endpoint:
/api/user/userprofile/:userId
- Method: GET
- Description: Fetches the profile of a specific user.
- Privacy: Private
- Endpoint:
/api/user/deleteprofile/:userId
- Method: DELETE
- Description: Deletes the user account.
- Privacy: Private
- Endpoint:
/api/user/logout
- Method: GET
- Description: Logs out the user.
- Privacy: Private