- Clone this project.
- Go to the directory.
cd eshop-api- And then
npm installto install all dependecies.
- Prisma needs some information about your database. So, let we create
.envfile, copy inside of.env.exampleand changes this part by your database credential. In this project we will use MySQL.
DATABASE_URL = "mysql://user:password@localhost:3306/database_name"
- Also you can setup other variable in env file for later use.
- Migrating our model into database, we should run
npm run migrateornpx prisma migrate dev. - Last,
npm run devfor running our application.
- You can run seeder file in
databasefolder for filling up database, feel free to adjust how much data you need.
- We would using a dummy payment gateway, just clone this repository below, and setup the server at another port. Maka sure that application server running before doing payments.
git clone https://github.com/harrymahardhika/dummy-payment-gateway.git- Description: Authenticate a user and return an access token.
- Request parameters: None
- Request body:
username: The user's username.password: The user's password.
- Response:
token: The access token for the authenticated user.
- Description: Retrieve a list of all users.
- Request parameters: None
- Request body: None
- Response: An array of user objects.
- Description: Retrieve a specific user by ID.
- Request parameters:
id: The ID of the user.
- Request body: None
- Response: The user object.
- Description: Register a new user.
- Request parameters: None
- Request body:
username: The user's username.password: The user's password.
- Response: The newly created user object.
- Description: Update a specific user by ID.
- Request parameters:
id: The ID of the user.
- Request body: The fields to update.
- Response: The updated user object.
- Description: Deactivate a specific user by ID.
- Request parameters:
id: The ID of the user.
- Request body: None
- Response: The updated user object.
- Description: Permanently delete a specific user by ID.
- Request parameters:
id: The ID of the user.
- Request body: None
- Response: A success message.
- Description: Retrieve a list of all categories.
- Request parameters: None
- Request body: None
- Response: An array of category objects.
- Description: Retrieve a specific category by ID.
- Request parameters:
id: The ID of the category.
- Request body: None
- Response: The category object.
- Description: Create a new category.
- Request parameters: None
- Request body:
name: The name of the category.
- Response: The newly created category object.
- Description: Update a specific category by ID.
- Request parameters:
id: The ID of the category.
- Request body: The fields to update.
- Response: The updated category object.
- Description: Delete a specific category by ID.
- Request parameters:
id: The ID of the category.
- Request body: None
- Response: A success message.
-
Description: Retrieve a list of all products.
-
Request parameters: None
-
Request query:
/api/product?search=: search product by name/api/product?sort=: sort product by product field, default is sort by id/api/product?order=: order byascordesc/api/product?page=: choose what page that will show/api/product?limit=: limit products for one page
-
Request body: None
-
Response: An array of product objects.
- Description: Retrieve a specific product by ID.
- Request parameters:
id: The ID of the product.
- Request body: None
- Response: The product object.
- Description: Admin endpoint to create a new product.
- Request parameters: None
- Request body:
name: The name of the product.category_id: The ID of the category the product belongs to.
- Response: The newly created product object.
- Description: Create a new product.
- Request parameters: None
- Request body:
name: The name of the product.category_id: The ID of the category the product belongs to.
- Response: The newly created product object.
- Description: Admin endpoint to update a specific product by ID.
- Request parameters:
id: The ID of the product.
- Request body: The fields to update.
- Response: The updated product object.
- Description: Update a specific product by ID.
- Request parameters:
id: The ID of the product.
- Request body: The fields to update.
- Response: The updated product object.
- Description: Admin endpoint to soft delete a specific product by ID.
- Request parameters:
id: The ID of the product.
- Request body: None
- Response: The updated product object.
- Description: Soft delete a specific product by ID.
- Request parameters:
id: The ID of the product.
- Request body: None
- Response: The updated product object.
- Description: Admin endpoint to permanently delete a specific product by ID.
- Request parameters:
id: The ID of the product.
- Request body: None
- Response: A success message.
- Description: Admin endpoint to retrieve a list of all carts.
- Request parameters: None
- Request body: None
- Response: An array of cart objects.
- Description: Admin endpoint to retrieve a specific cart by ID.
- Request parameters:
id: The ID of the cart.
- Request body: None
- Response: The cart object.
- Description: Retrieve a list of all carts.
- Request parameters: None
- Request body: None
- Response: An array of cart objects.
- Description: Admin endpoint to create a new cart.
- Request parameters: None
- Request body:
user_id: The ID of the user the cart belongs to.
- Response: The newly created cart object.
- Description: Create a new cart.
- Request parameters: None
- Request body:
user_id: The ID of the user the cart belongs to.
- Response: The newly created cart object.
- Description: Admin endpoint to update a specific cart by ID.
- Request parameters:
id: The ID of the cart.
- Request body: The fields to update.
- Response: The updated cart object.
- Description: Update a specific cart by ID.
- Request parameters:
id: The ID of the cart.
- Request body: The fields to update.
- Response: The updated cart object.
- Description: Admin endpoint to delete a specific cart by ID.
- Request parameters:
id: The ID of the cart.
- Request body: None
- Response: A success message.
- Description: Delete a specific cart by ID.
- Request parameters:
id: The ID of the cart.
- Request body: None
- Response: A success message.
- Description: Admin endpoint to retrieve a list of all orders.
- Request parameters: None
- Request body: None
- Response: An array of order objects.
- Description: Seller endpoint to retrieve a list of all orders.
- Request parameters: None
- Request body: None
- Response: An array of order objects.
- Description: Retrieve a list of all orders.
- Request parameters: None
- Request body: None
- Response: An array of order objects.
- Description: Create a new order.
- Request parameters: None
- Request body:
user_id: The ID of the user the order belongs to.product_id: The ID of the product the order is for.
- Response: The newly created order object.
- Description: Process a payment for an order.
- Request parameters: None
- Request body:
order_id: The ID of the order to process payment for.payment_method: The method of payment.
- Response: A success message.
- Description: Update the status of a specific order by ID.
- Request parameters:
id: The ID of the order.
- Request body:
status: The new status of the order.
- Response: The updated order object.
- Description: Cancel a specific order by ID.
- Request parameters:
id: The ID of the order.
- Request body: None
- Response: A success message.