# README
About API
This is a fake REST API specifically built for my mobile application. It includes all the essential features required for a basic e-commerce application. This API uses mongoDB as database.
End points
Login
/api/v1/user/login POST
request
{
"email": "[email protected]",
"password":"examplePass"
}
Response
{
"token": "-",
"refreshToken": "-",
"userName": "example name",
"email": "[email protected]"
}
Register
/api/v1/user/register POST
{
"userName": "example name",
"email": "[email protected]",
"password":"examplePass"
}
Response
{
"token": "-",
"refreshToken": "-",
"userName": "example name",
"email": "[email protected]"
}
OAuth
/api/v1/user/oauth POST
{
"userName": "Berk OAuth",
"email": "[email protected]",
"oAuthId": "12434563563"
}
Response
{
"token": "-",
"refreshToken": "-",
"userName": "example name",
"email": "[email protected]"
}
login with refreshToken
/api/v1/user/oauth POST
header
Authorization
= refresh token
Response
{
"token": "-",
"refreshToken": "-",
"userName": "example name",
"email": "[email protected]"
}
Categories
Get all categories
/api/v1//categories/ GET
Response
{
"categories": [
{
"id": "671652995b41c8ea613df136",
"value": "headphone"
}
]
}
Shop
get items as filter
this request will return us max 10 products
/api/v1/shop/featured?search=&offset= GET
request
{
"category": "671652995b41c8ea613df136", // additional
"sortBy": "ascending/descending",
"minPrice": 30,
"maxPrice": 400
}
response
{
"products" :[
{
"id": "6717af4decddea45c1a064de",
"pictureName": "headphone.jpg",
"name": "TMA-2 HD Wireless",
"price": 300
},
]
}
Basket fetch
/api/v1/basket/ GET
response
{
"basket": [
{
"id": "67260023d0ee97422c630d53",
"product": {
"id": "6717af4decddea45c1a064de",
"pictureName": "headphone.jpg",
"name": "TMA-2 HD Wireless",
"price": 300
},
"count": 1
}
]
}
Basket Update
/api/v1/basket/update POST
request
{
"basketId": "671fda1b69e5fdfac40ae895",
"count": -1
}
Basket Add To Basket
/api/v1/basket/add POST
request
{
"productId": "6717af4decddea45c1a064de"
}
response
id: id of the basket
{
"id": "6717af4decddea45c1a064de"
}
Remove From basket
/api/v1/basket/removeOne DELETE
request
{
"basketId": "671fda1b69e5fdfac40ae895"
}
Clear Basket
/api/v1/basket/removeAll DELETE
IMAGE
/api/v1/image/{ImageFile} GET
Getting Started
Follow these steps to set up and run the project:
-
Download the Project
Clone the repository to your local machine:git clone https://github.com/BerkCicekler/e-commerce-audio-api cd e-commerce-api
-
Set Up Environment Variables
Create a .env file in the root directory and fill in the required variables:MONGO_URI="PASTE_YOUR_MONGO_URI" DB_NAME="YOUR_DB_NAME" JWT_SECRET="YOUR_SUPER_SECRET_KEY"
-
Prepare the Database
- Create all the necessary collections in your database.
- Import the dummy data into the appropriate collections.
- Dummy data files are located in the
/collectionDummyData/
directory.
-
Run the Project:
- Inside the project directory, execute the following command:
go run main.go
- If the
go run
command fails, build the project manually:go build ./main
- Inside the project directory, execute the following command: