- Customer Privileges: Shoppers with basic access to browse and make purchases.
- Admin Role: Administrators have full control over the platform.
- User Registration: Enable customers to create accounts.
- User Authentication: Implement JWT-based authentication mechanisms to secure user sessions.
- User Profiles: Enable users to view and update their profiles.
- Order Workflow Management: Handle the entire order lifecycle, from creation to status updates and maintaining order history.
- Payment Gateway Integration: Integrate with stripe payment gateway for seamless transactions.
- Products: Create, update, and delete products.
- Categories and Sub Categories: Organize products into categories and sub categories for easy finding.
- Inventory Control: Keep track of product availability and stock levels.
- Shopping Cart: Allow users to effortlessly add, remove, and update products in their carts.
- Checkout: Optimize the checkout process, ensuring swift and secure transactions.
- JWT Tokenization: Implement robust JSON Web Token mechanisms to fortify authentication.
NestJS Architecture
ER Diagram
- NestJS - A progressive Node.js framework for building scalable and efficient server-side applications.
- TypeScript - A superset of JavaScript that brings static typing to the language, enhancing code maintainability and developer productivity.
- TypeORM (Object-Relational Mapping) - A powerful and flexible ORM that simplifies database interactions in TypeScript applications.
- MySQL - A popular relational database management system used for efficient and structured data storage.
- Passport.js - A flexible authentication middleware for Node.js applications, facilitating user authentication strategies.
- JWT - A secure and compact method for token-based authentication, enhancing the security of user sessions.
- Bcrypt - A library for hashing passwords, enhancing security by securely storing user credentials.
- Swagger - A tool for documenting and testing APIs, providing a user-friendly interface for developers to explore endpoints.
- Stripe - A widely-used platform for handling online payments securely and efficiently.
- NestJS CLI: Command-line tools for scaffolding and managing NestJS projects.
- ESLint (Code Linter):: A linting tool for identifying and fixing common programming errors and stylistic issues.
- Prettier: A code formatting tool to maintain consistent and readable code across the project.
- Node (Version 18.18.0 or higher)
- NPM (The Node.js package manager. Installed with Node.js)
- Mysql: (latest)
- Clone this repository and cd into the project directory:
git clone https://github.com/moinulhossainmahim/shop-api.git cd shop-api
- Replace
env.example
file to.env
- Create Account in stripe and save stripe keys.
- Update env environment variables
MYSQL_ROOT_PASSWORD = "YOUR MYSQL DATABASE ROOT PASSWORD" MYSQL_DATABASE = "YOUR MYSQL DATABASE" DB_HOST = "YOUR MYSQL DATABASE HOST" DB_PORT = "YOUR MYSQL DATABASE PORT" DB_USERNAME = "YOUR MYSQL DATABASE USER NAME" DB_PASSWORD = "YOUR MYSQL DATABASE PASSWORD" DB_NAME = "YOUR MYSQL DATABASE NAME" JWT_SECRET = "YOUR JWT SECRET" NODE_ENV = "development" STRIPE_SECRET_KEY = "YOUR STRIPE SECRET KEY" STRIPE_CURRENCY = "THE CURRENCY OF STRIPE PAYMENT"
- Run
npm install
inside the main project folder to install all dependencies from NPM.
- Create A Mysql Database and replace database connection variables in
.env
file.
-
npm run start:dev
-
Install Docker First
-
Check the official Docker documentation for information how to install Docker on your operating system. And then install Docker and supporting tools.
-
Build the docker images
docker-compose build
-
Start the containers
docker-compose up
-
If everyting setup correctly and your containers are running then you will get the application running in localhost:3000
-
Update port mappings in
docker-compose.yml
file if you want to run in different port
-
npm run migration:generate ./src/migration/[MIGRATION_TITLE] npm run migration:run
GET
/auth/signin
curl -X 'GET' \ 'http://localhost:3000/auth/signin \
-H 'accept: application/json'
-H 'Content-Type: application/json' \
-d '{
"email": "moinulhossain@gmail.com",
"password": "Moinulpassword123",
}'
http://localhost:3000/auth/signin
{
"success": true,
"content": {
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiTW9pbnVsIEhvc3NhaW4iLCJ1c2VySWQiOiJiNWM3OGQ0Zi1hMWQzLTQ5MDktOWEzYi03ZjM1NDk2YTU1M2YiLCJpYXQiOjE3MDQ3MTUzMTYsImV4cCI6MTcwNDcxODkxNn0.aEOVyViMFnlp0MZVjBMFiV9BiBN9yBj_-1JLmeh3bKk"
},
"message": "sign in successfully"
}
POST
/auth/signup
curl -X 'POST' \
'http://localhost:3000/auth/signup' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"fullName": "Moinul Hossain",
"password": "Mahim123@",
"email": "moinulhossainmahim@gmail.com",
"contact": "01732748262"
}'
http://localhost:3000/auth/signup
{
"success": true,
"content": [],
"message": "sign up successfully"
}
POST
/auth/google/signin
curl -X 'POST' \
'http://localhost:3000/auth/google/signin' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"code": "code from google auth"
}'
http://localhost:3000/auth/google/signin
{
"success": true,
"content": [],
"message": "sign in successfully"
}
GET
/users
curl -X 'GET' \ 'http://localhost:3000/users \
-H 'accept: application/json'
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiTW9pbnVsIEhvc3NhaW4iLCJ1c2VySWQiOiJiNWM3OGQ0Zi1hMWQzLTQ5MDktOWEzYi03ZjM1NDk2YTU1M2YiLCJpYXQiOjE3MDQ3MTUzMTYsImV4cCI6MTcwNDcxODkxNn0.aEOVyViMFnlp0MZVjBMFiV9BiBN9yBj_-1JLmeh3bKk'
http://localhost:3000/users
{
"success": true,
"content": [
{
"id": "b5c78d4f-a1d3-4909-9a3b-7f35496a553f",
"fullName": "Moinul Hossain",
"avatar": "",
"email": "moinulhossainmahim@gmail.com",
"userType": "admin",
"status": "active",
"address": []
}
],
"meta": {},
"message": "Fetched users successfully"
}
User need to be admin to access this endpoint
GET
/users/profile
curl -X 'GET' \ 'http://localhost:3000/users/profile \
-H 'accept: application/json'
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiTW9pbnVsIEhvc3NhaW4iLCJ1c2VySWQiOiJiNWM3OGQ0Zi1hMWQzLTQ5MDktOWEzYi03ZjM1NDk2YTU1M2YiLCJpYXQiOjE3MDQ3MTUzMTYsImV4cCI6MTcwNDcxODkxNn0.aEOVyViMFnlp0MZVjBMFiV9BiBN9yBj_-1JLmeh3bKk'
http://localhost:3000/users/profile
{
"success": true,
"content": {
"id": "b5c78d4f-a1d3-4909-9a3b-7f35496a553f",
"fullName": "Moinul Hossain",
"avatar": "",
"email": "moinulhossainmahim@gmail.com",
"contact": "01732748262",
"userType": "admin",
"status": "active",
"address": []
},
"message": "Fetched user successfully"
}
PATCH
/users/{userId}/update-password
curl -X 'GET' \ 'http://localhost:3000/users/b5c78d4f-a1d3-4909-9a3b-7f35496a553f/update-password \
-H 'accept: application/json'
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiTW9pbnVsIEhvc3NhaW4iLCJ1c2VySWQiOiJiNWM3OGQ0Zi1hMWQzLTQ5MDktOWEzYi03ZjM1NDk2YTU1M2YiLCJpYXQiOjE3MDQ3MTUzMTYsImV4cCI6MTcwNDcxODkxNn0.aEOVyViMFnlp0MZVjBMFiV9BiBN9yBj_-1JLmeh3bKk'
-d '{
"oldPassword": "Hellomahim123@",
"newPassword": "Hellomahim12@"
}'
http://localhost:3000/users/{userId}/update-password
{
"data": [],
"message": "Password updated successfully",
"success": true
}
PATCH
/users/{userId}
curl -X 'GET' \ 'http://localhost:3000/users/b5c78d4f-a1d3-4909-9a3b-7f35496a553f \
-H 'accept: application/json'
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiTW9pbnVsIEhvc3NhaW4iLCJ1c2VySWQiOiJiNWM3OGQ0Zi1hMWQzLTQ5MDktOWEzYi03ZjM1NDk2YTU1M2YiLCJpYXQiOjE3MDQ3MTUzMTYsImV4cCI6MTcwNDcxODkxNn0.aEOVyViMFnlp0MZVjBMFiV9BiBN9yBj_-1JLmeh3bKk'
-d '{
"avatar": Image,
"contact": "019827373661",
"email": "test@gmail.com",
"fullName": "Test name"
}'
http://localhost:3000/users/{userId}
{
"success": true,
"content": {
"id": "b5c78d4f-a1d3-4909-9a3b-7f35496a553f",
"fullName": "Moinul Hossain",
"avatar": "",
"email": "moinulhossainmahim@gmail.com",
"contact": "01732748262",
"userType": "admin",
"status": "active",
"address": []
},
"message": "Updated user successfully"
}
POST
/categories
curl -X 'POST' \ 'http://localhost:3000/categories \
-H 'accept: application/json'
-H 'Content-Type: application/json'
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiTW9pbnVsIEhvc3NhaW4iLCJ1c2VySWQiOiJiNWM3OGQ0Zi1hMWQzLTQ5MDktOWEzYi03ZjM1NDk2YTU1M2YiLCJpYXQiOjE3MDQ3MTUzMTYsImV4cCI6MTcwNDcxODkxNn0.aEOVyViMFnlp0MZVjBMFiV9BiBN9yBj_-1JLmeh3bKk'
-d '{
"file": Img,
"name": "Fruits and Vegetables",
"description": "Category for fruits and vegetables items",
"slug": "fruits-and-vegetables"
}'
http://localhost:3000/categories
{
"success": true,
"content": {
"name": "Fruits and Vegetables",
"slug": "fruits-and-vegetables",
"description": "This category is for fruits and vegetables",
"icon": "http://localhost:3000/categories/pictures/apple_1704722889181.png",
"id": "365079f8-ae27-40da-9669-b0a5b956cc4d"
},
"message": "Category created successfully"
}
GET
/categories
curl -X 'GET' \ 'http://localhost:3000/categories \
-H 'accept: application/json'
http://localhost:3000/categories
{
"success": true,
"content": [
{
"id": "365079f8-ae27-40da-9669-b0a5b956cc4d",
"name": "Fruits and Vegetables",
"slug": "fruits-and-vegetables",
"description": "This category is for fruits and vegetables",
"icon": "http://localhost:3000/categories/pictures/apple_1704722889181.png",
"subCategories": []
}
],
"meta": {},
"message": "Fetched categories successfully"
}
GET
/categories/{categoryId}
curl -X 'GET' \ 'http://localhost:3000/categories/42fc242a-b020-45d0-82e7-c5e37f3a759d \
-H 'accept: application/json'
http://localhost:3000/categories/42fc242a-b020-45d0-82e7-c5e37f3a759d
{
"success": true,
"content": {
"id": "365079f8-ae27-40da-9669-b0a5b956cc4d",
"name": "Fruits and Vegetables",
"slug": "fruits-and-vegetables",
"description": "This category is for fruits and vegetables",
"icon": "http://localhost:3000/categories/pictures/apple_1704722889181.png"
},
"message": "Fetched category successfully"
}
PATCH
/categories/{categoryId}
curl -X 'PATCH' \ 'http://localhost:3000/categories/42fc242a-b020-45d0-82e7-c5e37f3a759d \
-H 'accept: application/json'
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiTW9pbnVsIEhvc3NhaW4iLCJ1c2VySWQiOiJiNWM3OGQ0Zi1hMWQzLTQ5MDktOWEzYi03ZjM1NDk2YTU1M2YiLCJpYXQiOjE3MDQ3MTUzMTYsImV4cCI6MTcwNDcxODkxNn0.aEOVyViMFnlp0MZVjBMFiV9BiBN9yBj_-1JLmeh3bKk'
-d '{
"name": "Fruits and vegetables",
"slug": "fruits-and-vegetables",
"description": "This category is for fruits and vegetables item.",
"icon": Image,
}'
http://localhost:3000/categories/42fc242a-b020-45d0-82e7-c5e37f3a759d
{
"success": true,
"content": {
"id": "365079f8-ae27-40da-9669-b0a5b956cc4d",
"name": "Fruits and Vegetables",
"slug": "fruits-and-vegetables",
"description": "This category is for fruits and vegetables",
"icon": "http://localhost:3000/categories/pictures/apple_1704722889181.png"
},
"message": "Category updated successfully"
}
DELETE
/categories/{categoryId}
curl -X 'DELETE' \ 'http://localhost:3000/categories/42fc242a-b020-45d0-82e7-c5e37f3a759d \
-H 'accept: application/json'
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiTW9pbnVsIEhvc3NhaW4iLCJ1c2VySWQiOiJiNWM3OGQ0Zi1hMWQzLTQ5MDktOWEzYi03ZjM1NDk2YTU1M2YiLCJpYXQiOjE3MDQ3MTUzMTYsImV4cCI6MTcwNDcxODkxNn0.aEOVyViMFnlp0MZVjBMFiV9BiBN9yBj_-1JLmeh3bKk'
http://localhost:3000/categories/42fc242a-b020-45d0-82e7-c5e37f3a759d
{
"success": true,
"content": [],
"message": "Delete category successfully"
}
POST
/sub-categories
curl -X 'POST' \ 'http://localhost:3000/sub-categories \
-H 'accept: application/json'
-H 'Content-Type: application/json'
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiTW9pbnVsIEhvc3NhaW4iLCJ1c2VySWQiOiJiNWM3OGQ0Zi1hMWQzLTQ5MDktOWEzYi03ZjM1NDk2YTU1M2YiLCJpYXQiOjE3MDQ3MTUzMTYsImV4cCI6MTcwNDcxODkxNn0.aEOVyViMFnlp0MZVjBMFiV9BiBN9yBj_-1JLmeh3bKk'
-d '{
"name": "Fruits",
"description": "This is for fruits sub category",
"slug": "fruits",
"categoryId": "365079f8-ae27-40da-9669-b0a5b956cc4d"
}'
http://localhost:3000/sub-categories
{
"success": true,
"content": [
{
"name": "Fruits",
"description": "This is for fruits sub category",
"slug": "fruits",
"id": "f2e547e6-86cc-407e-8b68-482767c75f49"
}
],
"message": "Sub category created successfully"
}
GET
/sub-categories
curl -X 'GET' \ 'http://localhost:3000/sub-categories \
-H 'accept: application/json'
http://localhost:3000/sub-categories
{
"success": true,
"content": [
{
"id": "f2e547e6-86cc-407e-8b68-482767c75f49",
"name": "Fruits",
"description": "This is for fruits sub category",
"slug": "fruits",
"category": {
"id": "365079f8-ae27-40da-9669-b0a5b956cc4d",
"name": "Fruits and Vegetables",
"slug": "fruits-and-vegetables",
"description": "This category is for fruits and vegetables item.",
"icon": "http://localhost:3000/categories/pictures/apple_1704722889181.png"
}
}
],
"meta": {},
"message": "Fetched sub categories successfully"
}
PATCH
/sub-categories/{subCategoryId}
curl -X 'PATCH' \ 'http://localhost:3000/sub-categories/42fc242a-b020-45d0-82e7-c5e37f3a759d \
-H 'accept: application/json'
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiTW9pbnVsIEhvc3NhaW4iLCJ1c2VySWQiOiJiNWM3OGQ0Zi1hMWQzLTQ5MDktOWEzYi03ZjM1NDk2YTU1M2YiLCJpYXQiOjE3MDQ3MTUzMTYsImV4cCI6MTcwNDcxODkxNn0.aEOVyViMFnlp0MZVjBMFiV9BiBN9yBj_-1JLmeh3bKk'
-d '{
"name": "Update sub category",
"description": "Fruits sub cat",
"slug": "fruits-sub-cat",
"categoryId": "365079f8-ae27-40da-9669-b0a5b956cc4d"
}'
http://localhost:3000/sub-categories/42fc242a-b020-45d0-82e7-c5e37f3a759d
{
"success": true,
"content": {
"name": "Update sub category",
"description": "Fruits sub cat",
"slug": "fruits-sub-cat",
"categoryId": "365079f8-ae27-40da-9669-b0a5b956cc4d"
},
"message": "sub category updated successfully"
}
DELETE
/sub-categories/{categoryId}
curl -X 'DELETE' \ 'http://localhost:3000/sub-categories/42fc242a-b020-45d0-82e7-c5e37f3a759d \
-H 'accept: application/json'
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiTW9pbnVsIEhvc3NhaW4iLCJ1c2VySWQiOiJiNWM3OGQ0Zi1hMWQzLTQ5MDktOWEzYi03ZjM1NDk2YTU1M2YiLCJpYXQiOjE3MDQ3MTUzMTYsImV4cCI6MTcwNDcxODkxNn0.aEOVyViMFnlp0MZVjBMFiV9BiBN9yBj_-1JLmeh3bKk'
http://localhost:3000/sub-categories/42fc242a-b020-45d0-82e7-c5e37f3a759d
{
"success": true,
"content": [],
"message": "Delete sub category successfully"
}
POST
/wishlists/{productId}
curl -X 'POST' \ 'http://localhost:3000/wishlists/365079f8-ae27-40da-9669-b0a5b956cc4d \
-H 'accept: application/json'
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiTW9pbnVsIEhvc3NhaW4iLCJ1c2VySWQiOiJiNWM3OGQ0Zi1hMWQzLTQ5MDktOWEzYi03ZjM1NDk2YTU1M2YiLCJpYXQiOjE3MDQ3MTUzMTYsImV4cCI6MTcwNDcxODkxNn0.aEOVyViMFnlp0MZVjBMFiV9BiBN9yBj_-1JLmeh3bKk'
http://localhost:3000/wishlists/365079f8-ae27-40da-9669-b0a5b956cc4d
{
"success": true,
"content": [],
"message": "Added to wishlist successfully"
}
GET
/wishlists
curl -X 'GET' \ 'http://localhost:3000/wishlists \
-H 'accept: application/json'
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiTW9pbnVsIEhvc3NhaW4iLCJ1c2VySWQiOiJiNWM3OGQ0Zi1hMWQzLTQ5MDktOWEzYi03ZjM1NDk2YTU1M2YiLCJpYXQiOjE3MDQ3MTUzMTYsImV4cCI6MTcwNDcxODkxNn0.aEOVyViMFnlp0MZVjBMFiV9BiBN9yBj_-1JLmeh3bKk'
http://localhost:3000/wishlists
{
"success": true,
"content": [
{
"id": "365079f8-ae27-40da-9669-b0a5b956cc4d",
"product": {
"id": "365079f8-ae27-40da-9669-b0a5b956cc4d",
}
}
],
"meta": {
"page": 1,
"take": 10,
"itemCount": 1,
"pageCount": 1,
"hasPreviousPage": false,
"hasNextPage": false
},
"message": "Fetched wishlists successfully"
}
DELETE
/wishlists/{wishlistId}
curl -X 'DELETE' \ 'http://localhost:3000/wishlists/42fc242a-b020-45d0-82e7-c5e37f3a759d \
-H 'accept: application/json'
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiTW9pbnVsIEhvc3NhaW4iLCJ1c2VySWQiOiJiNWM3OGQ0Zi1hMWQzLTQ5MDktOWEzYi03ZjM1NDk2YTU1M2YiLCJpYXQiOjE3MDQ3MTUzMTYsImV4cCI6MTcwNDcxODkxNn0.aEOVyViMFnlp0MZVjBMFiV9BiBN9yBj_-1JLmeh3bKk'
http://localhost:3000/wishlists/42fc242a-b020-45d0-82e7-c5e37f3a759d
{
"success": true,
"content": [],
"message": "Wishlist removed successfully"
}
POST
/address
curl -X 'POST' \ 'http://localhost:3000/address \
-H 'accept: application/json'
-H 'Content-Type: application/json'
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiTW9pbnVsIEhvc3NhaW4iLCJ1c2VySWQiOiJiNWM3OGQ0Zi1hMWQzLTQ5MDktOWEzYi03ZjM1NDk2YTU1M2YiLCJpYXQiOjE3MDQ3MTUzMTYsImV4cCI6MTcwNDcxODkxNn0.aEOVyViMFnlp0MZVjBMFiV9BiBN9yBj_-1JLmeh3bKk'
-d '{
"title": "test",
"country": "test country",
"city": "test city",
"zip": "test zip",
"state": "test state",
"streetAddress": "test streetAdress",
"addressType": "shipping"
}'
http://localhost:3000/address
{
"success": true,
"content": {
"title": "test",
"country": "test country",
"city": "test city",
"state": "test state",
"zip": "test zip",
"streetAddress": "test streetAdress",
"addressType": "shipping",
"id": "40c1b9bf-e248-40b9-8a81-53971285b449",
"isActive": true
},
"message": "Address added successfully"
}
GET
/address
curl -X 'GET' \ 'http://localhost:3000/address \
-H 'accept: application/json'
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiTW9pbnVsIEhvc3NhaW4iLCJ1c2VySWQiOiJiNWM3OGQ0Zi1hMWQzLTQ5MDktOWEzYi03ZjM1NDk2YTU1M2YiLCJpYXQiOjE3MDQ3MTUzMTYsImV4cCI6MTcwNDcxODkxNn0.aEOVyViMFnlp0MZVjBMFiV9BiBN9yBj_-1JLmeh3bKk'
http://localhost:3000/address
{
"success": true,
"content": [
{
"id": "40c1b9bf-e248-40b9-8a81-53971285b449",
"title": "test",
"country": "test country",
"city": "test city",
"state": "test state",
"zip": "test zip",
"streetAddress": "test streetAdress",
"addressType": "shipping",
"isActive": true
}
],
"meta": {},
"message": "Fetched addresses successfully"
}
PATCH
/address/{addressId}
curl -X 'PATCH' \ 'http://localhost:3000/address/42fc242a-b020-45d0-82e7-c5e37f3a759d \
-H 'accept: application/json'
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiTW9pbnVsIEhvc3NhaW4iLCJ1c2VySWQiOiJiNWM3OGQ0Zi1hMWQzLTQ5MDktOWEzYi03ZjM1NDk2YTU1M2YiLCJpYXQiOjE3MDQ3MTUzMTYsImV4cCI6MTcwNDcxODkxNn0.aEOVyViMFnlp0MZVjBMFiV9BiBN9yBj_-1JLmeh3bKk'
-d '{
"addressType": "billing"
}'
http://localhost:3000/address/42fc242a-b020-45d0-82e7-c5e37f3a759d
{
"success": true,
"content": {
"id": "40c1b9bf-e248-40b9-8a81-53971285b449",
"title": "test",
"country": "test country",
"city": "test city",
"state": "test state",
"zip": "test zip",
"streetAddress": "test streetAdress",
"addressType": "billing",
"isActive": true
},
"message": "Address updated successfully"
}
DELETE
/address/{addressId}
curl -X 'DELETE' \ 'http://localhost:3000/address/42fc242a-b020-45d0-82e7-c5e37f3a759d \
-H 'accept: application/json' \
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiTW9pbnVsIEhvc3NhaW4iLCJ1c2VySWQiOiJiNWM3OGQ0Zi1hMWQzLTQ5MDktOWEzYi03ZjM1NDk2YTU1M2YiLCJpYXQiOjE3MDQ3MTUzMTYsImV4cCI6MTcwNDcxODkxNn0.aEOVyViMFnlp0MZVjBMFiV9BiBN9yBj_-1JLmeh3bKk'
http://localhost:3000/address/42fc242a-b020-45d0-82e7-c5e37f3a759d
{
"success": true,
"content": [],
"message": "Address Deleted successfully"
}
POST
/products
curl -X 'POST' \ 'http://localhost:3000/products \
-H 'accept: application/json'
-H 'Content-Type: application/json'
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiTW9pbnVsIEhvc3NhaW4iLCJ1c2VySWQiOiJiNWM3OGQ0Zi1hMWQzLTQ5MDktOWEzYi03ZjM1NDk2YTU1M2YiLCJpYXQiOjE3MDQ3MTUzMTYsImV4cCI6MTcwNDcxODkxNn0.aEOVyViMFnlp0MZVjBMFiV9BiBN9yBj_-1JLmeh3bKk'
-d '{
"name": "Apples",
"desc": "An apple is a sweet, edible fruit produced by an apple tree (Malus domestica). Apple trees are ... The skin of ripe apples is generally red, yellow, green, pink, or russetted, though many bi- or tri-colored cultivars may be found.",
"status": "PUBLISHED",
"unit": "kg",
"price": 2,
"salePrice": 1.6,
"quantity": 300,
"sku": "20240108-P01",
"slug": "apples",
"images": Image[],
"categoryId": "365079f8-ae27-40da-9669-b0a5b956cc4d",
"subCategoryId": "365079f8-ae27-40da-9669-b0a5b956cc4d"
}'
http://localhost:3000/products
{
"success": true,
"content": {
"name": "Apples",
"desc": "An apple is a sweet, edible fruit produced by an apple tree (Malus domestica). Apple trees are ... The skin of ripe apples is generally red, yellow, green, pink, or russetted, though many bi- or tri-colored cultivars may be found.",
"status": "PUBLISHED",
"unit": "kg",
"price": 2,
"salePrice": 1.6,
"quantity": 300,
"sku": "20240108-P01",
"slug": "apples",
"featuredImg": "http://localhost:3000/products/pictures/apple-1_1704734677462.webp",
"galleryImg": [
"http://localhost:3000/products/pictures/apple-2_1704734677463.webp",
"http://localhost:3000/products/pictures/apple_1704734677463.webp"
],
"id": "64eb19a5-9379-4c20-b18f-dcf1f193c230",
"createdAt": "2024-01-08T17:24:37.485Z"
},
"message": "Product created successfully"
}
GET
/products
curl -X 'GET' \ 'http://localhost:3000/products \
-H 'accept: application/json'
http://localhost:3000/products
{
"success": true,
"content": [
{
"id": "64eb19a5-9379-4c20-b18f-dcf1f193c230",
"createdAt": "2024-01-08T17:24:37.485Z",
"name": "Apples",
"desc": "An apple is a sweet, edible fruit produced by an apple tree (Malus domestica). Apple trees are ... The skin of ripe apples is generally red, yellow, green, pink, or russetted, though many bi- or tri-colored cultivars may be found.",
"status": "PUBLISHED",
"featuredImg": "http://localhost:3000/products/pictures/apple-1_1704734677462.webp",
"galleryImg": [
"http://localhost:3000/products/pictures/apple-2_1704734677463.webp",
"http://localhost:3000/products/pictures/apple_1704734677463.webp"
],
"unit": "kg",
"price": "2.00",
"salePrice": "1.60",
"quantity": 300,
"sku": "20240108-P01",
"slug": "apples",
"categories": [
{
"id": "365079f8-ae27-40da-9669-b0a5b956cc4d",
"name": "Fruits and Vegetables",
"slug": "fruits-and-vegetables",
"description": "This category is for fruits and vegetables item.",
"icon": "http://localhost:3000/categories/pictures/apple_1704722889181.png"
}
],
"subcategories": [
{
"id": "f2e547e6-86cc-407e-8b68-482767c75f49",
"name": "Fruits",
"description": "This is for fruits sub category",
"slug": "fruits"
}
]
}
],
"meta": {
"page": 1,
"take": 10,
"itemCount": 1,
"pageCount": 1,
"hasPreviousPage": false,
"hasNextPage": false
},
"message": "Fetch products successfully"
}
GET
/products/{productId}
curl -X 'GET' \ 'http://localhost:3000/products/64eb19a5-9379-4c20-b18f-dcf1f193c230 \
-H 'accept: application/json'
http://localhost:3000/products/64eb19a5-9379-4c20-b18f-dcf1f193c230
{
"success": true,
"content": {
"id": "64eb19a5-9379-4c20-b18f-dcf1f193c230",
"createdAt": "2024-01-08T17:24:37.485Z",
"name": "Apples",
"desc": "An apple is a sweet, edible fruit produced by an apple tree (Malus domestica). Apple trees are ... The skin of ripe apples is generally red, yellow, green, pink, or russetted, though many bi- or tri-colored cultivars may be found.",
"status": "PUBLISHED",
"featuredImg": "http://localhost:3000/products/pictures/apple-1_1704734677462.webp",
"galleryImg": [
"http://localhost:3000/products/pictures/apple-2_1704734677463.webp",
"http://localhost:3000/products/pictures/apple_1704734677463.webp"
],
"unit": "kg",
"price": "2.00",
"salePrice": "1.60",
"quantity": 300,
"sku": "20240108-P01",
"slug": "apples"
},
"message": "Get product successfully"
}
PATCH
/products/{productId}
curl -X 'PATCH' \ 'http://localhost:3000/products/64eb19a5-9379-4c20-b18f-dcf1f193c230 \
-H 'accept: application/json'
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiTW9pbnVsIEhvc3NhaW4iLCJ1c2VySWQiOiJiNWM3OGQ0Zi1hMWQzLTQ5MDktOWEzYi03ZjM1NDk2YTU1M2YiLCJpYXQiOjE3MDQ3MTUzMTYsImV4cCI6MTcwNDcxODkxNn0.aEOVyViMFnlp0MZVjBMFiV9BiBN9yBj_-1JLmeh3bKk'
-d '{
"desc": "An apple is a sweet. The skin of ripe apples is generally red, yellow, green, pink, or russetted, though many bi- or tri-colored cultivars may be found.",
}'
http://localhost:3000/products/64eb19a5-9379-4c20-b18f-dcf1f193c230
{
"success": true,
"content": {
"id": "64eb19a5-9379-4c20-b18f-dcf1f193c230",
"createdAt": "2024-01-08T17:24:37.485Z",
"name": "Apples",
"desc": "desc": "An apple is a sweet. The skin of ripe apples is generally red, yellow, green, pink, or russetted, though many bi- or tri-colored cultivars may be found.",
"status": "PUBLISHED",
"featuredImg": "http://localhost:3000/products/pictures/apple-1_1704734677462.webp",
"galleryImg": [
"http://localhost:3000/products/pictures/apple-2_1704734677463.webp",
"http://localhost:3000/products/pictures/apple_1704734677463.webp"
],
"unit": "kg",
"price": "2.00",
"salePrice": "1.60",
"quantity": 300,
"sku": "20240108-P01",
"slug": "apples"
},
"message": "product updated successfully"
}
DELETE
/products/{productId}
curl -X 'DELETE' \ 'http://localhost:3000/products/64eb19a5-9379-4c20-b18f-dcf1f193c230 \
-H 'accept: application/json'
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiTW9pbnVsIEhvc3NhaW4iLCJ1c2VySWQiOiJiNWM3OGQ0Zi1hMWQzLTQ5MDktOWEzYi03ZjM1NDk2YTU1M2YiLCJpYXQiOjE3MDQ3MTUzMTYsImV4cCI6MTcwNDcxODkxNn0.aEOVyViMFnlp0MZVjBMFiV9BiBN9yBj_-1JLmeh3bKk'
http://localhost:3000/products/64eb19a5-9379-4c20-b18f-dcf1f193c230
{
"success": true,
"content": [],
"message": "product deleted successfully"
}
POST
/orders
curl -X 'POST' \ 'http://localhost:3000/orders \
-H 'accept: application/json'
-H 'Content-Type: application/json'
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiTW9pbnVsIEhvc3NhaW4iLCJ1c2VySWQiOiJiNWM3OGQ0Zi1hMWQzLTQ5MDktOWEzYi03ZjM1NDk2YTU1M2YiLCJpYXQiOjE3MDQ3MTUzMTYsImV4cCI6MTcwNDcxODkxNn0.aEOVyViMFnlp0MZVjBMFiV9BiBN9yBj_-1JLmeh3bKk'
-d '{
"order_status": "pending",
"delivery_fee": 20,
"amount": 13,
"total": 33,
"payment_status": "pending",
"payment_method": "cashon",
"billingAddress": {
"id": "40c1b9bf-e248-40b9-8a81-53971285b449",
"title": "test",
"country": "test country",
"city": "test city",
"state": "test state",
"zip": "test zip",
"streetAddress": "test streetAdress",
"addressType": "billing",
"isActive": true
},
"shippingAddress": {
"id": "ff30fb95-06a9-4924-a09e-b4cce2c93795",
"title": "test",
"country": "test country",
"city": "test city",
"state": "test state",
"zip": "test zip",
"streetAddress": "test streetAdress",
"addressType": "billing",
"isActive": true
},
"orderItems": [
{
"productId": "64eb19a5-9379-4c20-b18f-dcf1f193c230",
"subtotal": 13,
"quantity": 1,
"unit_price": 1.60
}
]
}'
http://localhost:3000/orders
{
"success": true,
"content": {
"order_status": "pending",
"delivery_fee": 20,
"total": 33,
"amount": 13,
"payment_status": "pending",
"payment_method": "cashon",
"shippingAddress": {
"id": "ff30fb95-06a9-4924-a09e-b4cce2c93795",
"title": "test",
"country": "test country",
"city": "test city",
"state": "test state",
"zip": "test zip",
"streetAddress": "test streetAdress",
"addressType": "billing",
"isActive": true
},
"billingAddress": {
"id": "40c1b9bf-e248-40b9-8a81-53971285b449",
"title": "test",
"country": "test country",
"city": "test city",
"state": "test state",
"zip": "test zip",
"streetAddress": "test streetAdress",
"addressType": "billing",
"isActive": true
},
"orderItems": [
{
"id": "75813f1d-43e6-4270-a54b-f0e9c6471535",
"quantity": 1,
"unit_price": "1.60",
"subtotal": "13.00",
"product": {
"id": "64eb19a5-9379-4c20-b18f-dcf1f193c230",
"createdAt": "2024-01-08T17:24:37.485Z",
"name": "Apples",
"desc": "An apple is a sweet, edible fruit produced by an apple tree (Malus domestica). Apple trees are ... The skin of ripe apples is generally red, yellow, green, pink, or russetted, though many bi- or tri-colored cultivars may be found.",
"status": "PUBLISHED",
"featuredImg": "http://localhost:3000/products/pictures/apple-1_1704734677462.webp",
"galleryImg": [
"http://localhost:3000/products/pictures/apple-2_1704734677463.webp",
"http://localhost:3000/products/pictures/apple_1704734677463.webp"
],
"unit": "kg",
"price": "2.00",
"salePrice": "1.60",
"quantity": 300,
"sku": "20240108-P01",
"slug": "apples"
}
}
],
"id": "51851872-0ff0-44f0-bb0e-529d9bcbbb11",
"tracking_no": "20240105122035886-8317",
"order_date": "2024-01-08T18:43:18.000Z"
},
"message": "Order placed successfully"
}
GET
/orders
curl -X 'GET' \ 'http://localhost:3000/orders \
-H 'accept: application/json'
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiTW9pbnVsIEhvc3NhaW4iLCJ1c2VySWQiOiJiNWM3OGQ0Zi1hMWQzLTQ5MDktOWEzYi03ZjM1NDk2YTU1M2YiLCJpYXQiOjE3MDQ3MTUzMTYsImV4cCI6MTcwNDcxODkxNn0.aEOVyViMFnlp0MZVjBMFiV9BiBN9yBj_-1JLmeh3bKk'
http://localhost:3000/orders
{
"success": true,
"content": [
{
"id": "51851872-0ff0-44f0-bb0e-529d9bcbbb11",
"tracking_no": "20240105122035886-8317",
"order_date": "2024-01-08T18:43:18.000Z",
"order_status": "pending",
"delivery_fee": "20.00",
"total": "33.00",
"amount": "13.00",
"payment_status": "pending",
"payment_method": "cashon",
"orderItems": [
{
"id": "75813f1d-43e6-4270-a54b-f0e9c6471535",
"quantity": 1,
"unit_price": "1.60",
"subtotal": "13.00",
"product": {
"id": "64eb19a5-9379-4c20-b18f-dcf1f193c230",
"createdAt": "2024-01-08T17:24:37.485Z",
"name": "Apples",
"desc": "An apple is a sweet, edible fruit produced by an apple tree (Malus domestica). Apple trees are ... The skin of ripe apples is generally red, yellow, green, pink, or russetted, though many bi- or tri-colored cultivars may be found.",
"status": "PUBLISHED",
"featuredImg": "http://localhost:3000/products/pictures/apple-1_1704734677462.webp",
"galleryImg": [
"http://localhost:3000/products/pictures/apple-2_1704734677463.webp",
"http://localhost:3000/products/pictures/apple_1704734677463.webp"
],
"unit": "kg",
"price": "2.00",
"salePrice": "1.60",
"quantity": 300,
"sku": "20240108-P01",
"slug": "apples"
}
}
],
"shippingAddress": {
"id": "ff30fb95-06a9-4924-a09e-b4cce2c93795",
"title": "test",
"country": "test country",
"city": "test city",
"state": "test state",
"zip": "test zip",
"streetAddress": "test streetAdress",
"addressType": "billing",
"isActive": true
},
"billingAddress": {
"id": "40c1b9bf-e248-40b9-8a81-53971285b449",
"title": "test",
"country": "test country",
"city": "test city",
"state": "test state",
"zip": "test zip",
"streetAddress": "test streetAdress",
"addressType": "billing",
"isActive": true
}
}
],
"meta": {
"page": 1,
"take": 10,
"itemCount": 1,
"pageCount": 1,
"hasPreviousPage": false,
"hasNextPage": false
},
"message": "Orders fetched successfully"
}
GET
/orders/{orderId}
curl -X 'GET' \ 'http://localhost:3000/orders/51851872-0ff0-44f0-bb0e-529d9bcbbb11 \
-H 'accept: application/json'
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiTW9pbnVsIEhvc3NhaW4iLCJ1c2VySWQiOiJiNWM3OGQ0Zi1hMWQzLTQ5MDktOWEzYi03ZjM1NDk2YTU1M2YiLCJpYXQiOjE3MDQ3MTUzMTYsImV4cCI6MTcwNDcxODkxNn0.aEOVyViMFnlp0MZVjBMFiV9BiBN9yBj_-1JLmeh3bKk'
http://localhost:3000/orders/51851872-0ff0-44f0-bb0e-529d9bcbbb11
{
"success": true,
"content": {
"id": "51851872-0ff0-44f0-bb0e-529d9bcbbb11",
"tracking_no": "20240105122035886-8317",
"order_date": "2024-01-08T18:43:18.000Z",
"order_status": "pending",
"delivery_fee": "20.00",
"total": "33.00",
"amount": "13.00",
"payment_status": "pending",
"payment_method": "cashon",
"orderItems": [
{
"id": "75813f1d-43e6-4270-a54b-f0e9c6471535",
"quantity": 1,
"unit_price": "1.60",
"subtotal": "13.00",
"product": {
"id": "64eb19a5-9379-4c20-b18f-dcf1f193c230",
"createdAt": "2024-01-08T17:24:37.485Z",
"name": "Apples",
"desc": "An apple is a sweet, edible fruit produced by an apple tree (Malus domestica). Apple trees are ... The skin of ripe apples is generally red, yellow, green, pink, or russetted, though many bi- or tri-colored cultivars may be found.",
"status": "PUBLISHED",
"featuredImg": "http://localhost:3000/products/pictures/apple-1_1704734677462.webp",
"galleryImg": [
"http://localhost:3000/products/pictures/apple-2_1704734677463.webp",
"http://localhost:3000/products/pictures/apple_1704734677463.webp"
],
"unit": "kg",
"price": "2.00",
"salePrice": "1.60",
"quantity": 300,
"sku": "20240108-P01",
"slug": "apples"
}
}
],
"shippingAddress": {
"id": "ff30fb95-06a9-4924-a09e-b4cce2c93795",
"title": "test",
"country": "test country",
"city": "test city",
"state": "test state",
"zip": "test zip",
"streetAddress": "test streetAdress",
"addressType": "billing",
"isActive": true
},
"billingAddress": {
"id": "40c1b9bf-e248-40b9-8a81-53971285b449",
"title": "test",
"country": "test country",
"city": "test city",
"state": "test state",
"zip": "test zip",
"streetAddress": "test streetAdress",
"addressType": "billing",
"isActive": true
}
},
"message": "Fetched order successfully"
}
PATCH
/orders/{orderId}
curl -X 'PATCH' \ 'http://localhost:3000/orders/51851872-0ff0-44f0-bb0e-529d9bcbbb11 \
-H 'accept: application/json'
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiTW9pbnVsIEhvc3NhaW4iLCJ1c2VySWQiOiJiNWM3OGQ0Zi1hMWQzLTQ5MDktOWEzYi03ZjM1NDk2YTU1M2YiLCJpYXQiOjE3MDQ3MTUzMTYsImV4cCI6MTcwNDcxODkxNn0.aEOVyViMFnlp0MZVjBMFiV9BiBN9yBj_-1JLmeh3bKk'
-d '{
"order_status": "outForDelivery"
}'
http://localhost:3000/orders/51851872-0ff0-44f0-bb0e-529d9bcbbb11
{
"success": true,
"content": {
"id": "51851872-0ff0-44f0-bb0e-529d9bcbbb11",
"tracking_no": "20240105122035886-8317",
"order_date": "2024-01-08T18:43:18.000Z",
"order_status": "outForDelivery",
"delivery_fee": "20.00",
"total": "33.00",
"amount": "13.00",
"payment_status": "pending",
"payment_method": "cashon",
"orderItems": [
{
"id": "75813f1d-43e6-4270-a54b-f0e9c6471535",
"quantity": 1,
"unit_price": "1.60",
"subtotal": "13.00",
"product": {
"id": "64eb19a5-9379-4c20-b18f-dcf1f193c230",
"createdAt": "2024-01-08T17:24:37.485Z",
"name": "Apples",
"desc": "An apple is a sweet, edible fruit produced by an apple tree (Malus domestica). Apple trees are ... The skin of ripe apples is generally red, yellow, green, pink, or russetted, though many bi- or tri-colored cultivars may be found.",
"status": "PUBLISHED",
"featuredImg": "http://localhost:3000/products/pictures/apple-1_1704734677462.webp",
"galleryImg": [
"http://localhost:3000/products/pictures/apple-2_1704734677463.webp",
"http://localhost:3000/products/pictures/apple_1704734677463.webp"
],
"unit": "kg",
"price": "2.00",
"salePrice": "1.60",
"quantity": 300,
"sku": "20240108-P01",
"slug": "apples"
}
}
],
"shippingAddress": {
"id": "ff30fb95-06a9-4924-a09e-b4cce2c93795",
"title": "test",
"country": "test country",
"city": "test city",
"state": "test state",
"zip": "test zip",
"streetAddress": "test streetAdress",
"addressType": "billing",
"isActive": true
},
"billingAddress": {
"id": "40c1b9bf-e248-40b9-8a81-53971285b449",
"title": "test",
"country": "test country",
"city": "test city",
"state": "test state",
"zip": "test zip",
"streetAddress": "test streetAdress",
"addressType": "billing",
"isActive": true
}
},
"message": "Order updated successfully"
}
DELETE
/orders/{orderId}
curl -X 'DELETE' \ 'http://localhost:3000/orders/f67e8b81-90b4-45c0-96c6-44e54ced3124 \
-H 'accept: application/json'
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiTW9pbnVsIEhvc3NhaW4iLCJ1c2VySWQiOiJiNWM3OGQ0Zi1hMWQzLTQ5MDktOWEzYi03ZjM1NDk2YTU1M2YiLCJpYXQiOjE3MDQ3MTUzMTYsImV4cCI6MTcwNDcxODkxNn0.aEOVyViMFnlp0MZVjBMFiV9BiBN9yBj_-1JLmeh3bKk'
http://localhost:3000/orders/f67e8b81-90b4-45c0-96c6-44e54ced3124
{
"success": true,
"content": [],
"message": "Order deleted successfully"
}
POST
/orders/check-availability
curl -X 'POST' \ 'http://localhost:3000/products \
-H 'accept: application/json'
-H 'Content-Type: application/json'
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiTW9pbnVsIEhvc3NhaW4iLCJ1c2VySWQiOiJiNWM3OGQ0Zi1hMWQzLTQ5MDktOWEzYi03ZjM1NDk2YTU1M2YiLCJpYXQiOjE3MDQ3MTUzMTYsImV4cCI6MTcwNDcxODkxNn0.aEOVyViMFnlp0MZVjBMFiV9BiBN9yBj_-1JLmeh3bKk'
-d '{
"items": [
{
"productId": "64eb19a5-9379-4c20-b18f-dcf1f193c230",
"quantity": 21
}
]
}'
http://localhost:3000/orders/check-availability
{
"success": true,
"content": [],
"message": "Customer can continue the process"
}
POST
/cart
curl -X 'POST' \
'http://localhost:3000/cart' \
-H 'accept: application/json' \
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiTW9pbnVsIEhvc3NhaW4iLCJ1c2VySWQiOiJiNWM3OGQ0Zi1hMWQzLTQ5MDktOWEzYi03ZjM1NDk2YTU1M2YiLCJpYXQiOjE3MDQ3MTUzMTYsImV4cCI6MTcwNDcxODkxNn0.aEOVyViMFnlp0MZVjBMFiV9BiBN9yBj_-1JLmeh3bKk'
-d '
{
"productId": "64eb19a5-9379-4c20-b18f-dcf1f193c230",
"quantity": 10
}
'
http://localhost:3000/cart
{
"success": true,
"content": {
"total": 16,
"quantity": 10,
"product": {
"id": "64eb19a5-9379-4c20-b18f-dcf1f193c230",
"createdAt": "2024-01-08T17:24:37.485Z",
"name": "Apples",
"desc": "An apple is a sweet, edible fruit produced by an apple tree (Malus domestica). Apple trees are ... The skin of ripe apples is generally red, yellow, green, pink, or russetted, though many bi- or tri-colored cultivars may be found.",
"status": "PUBLISHED",
"featuredImg": "http://localhost:3000/products/pictures/apple-1_1704734677462.webp",
"galleryImg": [
"http://localhost:3000/products/pictures/apple-2_1704734677463.webp",
"http://localhost:3000/products/pictures/apple_1704734677463.webp"
],
"unit": "kg",
"price": "2.00",
"salePrice": "1.60",
"quantity": 300,
"sku": "20240108-P01",
"slug": "apples"
},
"productId": "64eb19a5-9379-4c20-b18f-dcf1f193c230",
"id": "95be3d0a-7719-499d-8178-37d416bfc2b7"
},
"message": "Add product to cart successfully"
}
GET
/cart
curl -X 'GET' \
'http://localhost:3000/cart' \
-H 'accept: application/json' \
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiTW9pbnVsIEhvc3NhaW4iLCJ1c2VySWQiOiJiNWM3OGQ0Zi1hMWQzLTQ5MDktOWEzYi03ZjM1NDk2YTU1M2YiLCJpYXQiOjE3MDQ3MTUzMTYsImV4cCI6MTcwNDcxODkxNn0.aEOVyViMFnlp0MZVjBMFiV9BiBN9yBj_-1JLmeh3bKk'
http://localhost:3000/cart
{
"success": true,
"content": [
{
"id": "95be3d0a-7719-499d-8178-37d416bfc2b7",
"total": 16,
"quantity": 10,
"productId": "64eb19a5-9379-4c20-b18f-dcf1f193c230",
"product": {
"id": "64eb19a5-9379-4c20-b18f-dcf1f193c230",
"createdAt": "2024-01-08T17:24:37.485Z",
"name": "Apples",
"desc": "An apple is a sweet, edible fruit produced by an apple tree (Malus domestica). Apple trees are ... The skin of ripe apples is generally red, yellow, green, pink, or russetted, though many bi- or tri-colored cultivars may be found.",
"status": "PUBLISHED",
"featuredImg": "http://localhost:3000/products/pictures/apple-1_1704734677462.webp",
"galleryImg": [
"http://localhost:3000/products/pictures/apple-2_1704734677463.webp",
"http://localhost:3000/products/pictures/apple_1704734677463.webp"
],
"unit": "kg",
"price": "2.00",
"salePrice": "1.60",
"quantity": 300,
"sku": "20240108-P01",
"slug": "apples"
}
}
],
"message": "Fetched cart successfully"
}
PUT
/cart/{productId}
curl -X 'PUT' \
'http://localhost:3000/cart/64eb19a5-9379-4c20-b18f-dcf1f193c230?quantity=15' \
-H 'accept: application/json' \
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiTW9pbnVsIEhvc3NhaW4iLCJ1c2VySWQiOiJiNWM3OGQ0Zi1hMWQzLTQ5MDktOWEzYi03ZjM1NDk2YTU1M2YiLCJpYXQiOjE3MDQ3MTUzMTYsImV4cCI6MTcwNDcxODkxNn0.aEOVyViMFnlp0MZVjBMFiV9BiBN9yBj_-1JLmeh3bKk'
http://localhost:3000/cart/64eb19a5-9379-4c20-b18f-dcf1f193c230?quantity=15
{
"success": true,
"content": {
"id": "95be3d0a-7719-499d-8178-37d416bfc2b7",
"total": 24,
"quantity": 15,
"productId": "64eb19a5-9379-4c20-b18f-dcf1f193c230",
"product": {
"id": "64eb19a5-9379-4c20-b18f-dcf1f193c230",
"createdAt": "2024-01-08T17:24:37.485Z",
"name": "Apples",
"desc": "An apple is a sweet, edible fruit produced by an apple tree (Malus domestica). Apple trees are ... The skin of ripe apples is generally red, yellow, green, pink, or russetted, though many bi- or tri-colored cultivars may be found.",
"status": "PUBLISHED",
"featuredImg": "http://localhost:3000/products/pictures/apple-1_1704734677462.webp",
"galleryImg": [
"http://localhost:3000/products/pictures/apple-2_1704734677463.webp",
"http://localhost:3000/products/pictures/apple_1704734677463.webp"
],
"unit": "kg",
"price": "2.00",
"salePrice": "1.60",
"quantity": 300,
"sku": "20240108-P01",
"slug": "apples"
}
},
"message": "Cart updated successfully"
}
DELETE
/cart/{productId}
curl -X 'DELETE' \
'http://localhost:3000/cart/64eb19a5-9379-4c20-b18f-dcf1f193c230' \
-H 'accept: application/json' \
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiTW9pbnVsIEhvc3NhaW4iLCJ1c2VySWQiOiJiNWM3OGQ0Zi1hMWQzLTQ5MDktOWEzYi03ZjM1NDk2YTU1M2YiLCJpYXQiOjE3MDQ3MTUzMTYsImV4cCI6MTcwNDcxODkxNn0.aEOVyViMFnlp0MZVjBMFiV9BiBN9yBj_-1JLmeh3bKk'
http://localhost:3000/cart/64eb19a5-9379-4c20-b18f-dcf1f193c230
{
"success": true,
"content": [],
"message": "Removed product from cart successfully"
}
DELETE
/cart/all
curl -X 'DELETE' \
'http://localhost:3000/cart/all' \
-H 'accept: application/json' \
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiTW9pbnVsIEhvc3NhaW4iLCJ1c2VySWQiOiJiNWM3OGQ0Zi1hMWQzLTQ5MDktOWEzYi03ZjM1NDk2YTU1M2YiLCJpYXQiOjE3MDQ3MTUzMTYsImV4cCI6MTcwNDcxODkxNn0.aEOVyViMFnlp0MZVjBMFiV9BiBN9yBj_-1JLmeh3bKk'
http://localhost:3000/cart/all
{
"success": true,
"content": [],
"message": "Cart removed successfully"
}