This is the backend code for my clone of OLX type website-ReBuy.
- The repo link of this project's frontend- Github-ReBuy-frontend
- This backend is hosted at ReBuy-backend
- It uses Express backend server and MongoDB as database.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
You will need Node.js and npm (which comes with Node) installed on your machine.
- Clone the repository:
git clone https://github.com/thecurious1-sudo/ReBuy-backend- Go to the project directory
cd ReBuy-backend- Install dependencies
npm install- Start the server
node index.jsThe app will open in your default browser at http://localhost:4000
To run this project, you will need to add the following environment variables to your root level .env file
JWT_SECRET- used to generate JSON WebToken for encoding purposeMONGODB_URL- mongoDB connection url( Use mongodb://0.0.0.0:27017/ReBuy if you are testing it locally or for online hosting, you can generate one from MongoDB Atlas platform)
I've created some sample data to seed the database. You can seed your DB by:-
cd seeds
node index.js POST /user/loginBody
| Field | Type | Description |
|---|---|---|
email |
string |
Required. Email Id |
password |
string |
Required. Password |
POST /user/signupBody
| Field | Type | Description |
|---|---|---|
name |
string |
Required. Name |
email |
string |
Required. Email Id |
password |
string |
Required. Password |
username |
string |
Username |
DOB |
string |
Date of Birth |
address |
string |
Address |
phone |
string |
Phone Number |
POST /products/Body
| Field | Type | Description |
|---|---|---|
token |
string |
Required. Authorization Token |
POST /products/newBody
| Field | Type | Description |
|---|---|---|
token |
string |
Required. Authorization Token |
name |
string |
Required. Name of the product |
description |
string |
Required. Description of the product |
price |
string |
Required. Price of product |
address |
string |
Required. Address of exchange |
POST /products/:idBody
| Field | Type | Description |
|---|---|---|
token |
string |
Required. Authorization Token |
Parameters
| Field | Type | Description |
|---|---|---|
id |
string |
Required. Product ID |
POST /orders/ - Get all the orders of logged in userBody
| Field | Type | Description |
|---|---|---|
token |
string |
Required. Authorization Token |
POST /orders/new - Create a new orderBody
| Field | Type | Description |
|---|---|---|
token |
string |
Required. Authorization Token |
productId |
string |
Required. Product ID |
POST /orders/:idBody
| Field | Type | Description |
|---|---|---|
token |
string |
Required. Authorization Token |
Parameters
| Field | Type | Description |
|---|---|---|
id |
string |
Required. Order ID |
POST /myItems/ - Get all the items posted by the userBody
| Field | Type | Description |
|---|---|---|
token |
string |
Required. Authorization Token |
POST /myItems/:idBody
| Field | Type | Description |
|---|---|---|
token |
string |
Required. Authorization Token |
Parameters
| Field | Type | Description |
|---|---|---|
id |
string |
Required. Item ID |