Skip to content

BerkCicekler/e-commerce-audio-api

Repository files navigation

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": "example@gmail.com",
    "password":"examplePass"
}

Response

{
   "token": "-",
   "refreshToken": "-",
   "userName": "example name",
   "email": "example@gmail.com"
}

Register

/api/v1/user/register POST

{
    "userName": "example name",
    "email": "example@gmail.com",
    "password":"examplePass"
}

Response

{
   "token": "-",
   "refreshToken": "-",
   "userName": "example name",
   "email": "example@gmail.com"
}

OAuth

/api/v1/user/oauth POST

{
    "userName": "Berk OAuth",
    "email": "wiroOAuth@gmail.com",
    "oAuthId": "12434563563"
}

Response

{
   "token": "-",
   "refreshToken": "-",
   "userName": "example name",
   "email": "example@gmail.com"
}

login with refreshToken

/api/v1/user/oauth POST
header
Authorization = refresh token Response

{
   "token": "-",
   "refreshToken": "-",
   "userName": "example name",
   "email": "example@gmail.com"
}

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:

  1. Download the Project
    Clone the repository to your local machine:

    git clone https://github.com/BerkCicekler/e-commerce-audio-api
    cd e-commerce-api  
    
  2. 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"  
    
  3. 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.
  4. 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  

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages