e-commerce-audio-api

command module
v0.0.0-...-91fbafe Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 7, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

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

Response

{
   "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHBpcmVzQXQiOjE3MzA1NDQ0MDgsInVzZXJJRCI6IjY3MTY0ZmRmMGYzOTFhMWZiMGZkNjE3ZSJ9.aZ5P1NTltnjs1F-CKLXfsSOBg6nHvUcMzm_h6uZ7ss4",
   "userName": "mal yay",
   "email": "wiro@gmail.com"
}
Register

/api/v1/user/register POST

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

Response

{
   "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHBpcmVzQXQiOjE3MzA1NDQ0MDgsInVzZXJJRCI6IjY3MTY0ZmRmMGYzOTFhMWZiMGZkNjE3ZSJ9.aZ5P1NTltnjs1F-CKLXfsSOBg6nHvUcMzm_h6uZ7ss4",
   "userName": "example name",
   "email": "example@gmail.com"
}
OAuth

/api/v1/user/oauth POST

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

Response

{
   "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHBpcmVzQXQiOjE3MzA1NDQ0MDgsInVzZXJJRCI6IjY3MTY0ZmRmMGYzOTFhMWZiMGZkNjE3ZSJ9.aZ5P1NTltnjs1F-CKLXfsSOBg6nHvUcMzm_h6uZ7ss4",
   "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

How do I use

download the project
create a .env file and fill the variables

MONGO_URI="PASTE your mongoURI"
DB_NAME="DB name"
JWT_SECRET="SUPERSECRET"

create all the collections in ur DB and import jsons the correct collections
the dumy datas can be found in: /collectionDumData/
run go run main.go command inside the project directory

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
cmd
api
service

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL