- Set up local mysql server
- Using MySQL cli, run
$mysql> source \this_repo\db\db.sql;
- Modify MySQL credentials to
app.js
on line 27 - Run
npm install
on repo directory - Run node app.js
- Server should now be running on
localhost:8000/
- store frontpage, fetches all products
- fetches details of a product with id of productId
- adds the product once to the cart
Note: If quantity of the product in the cart is equal to the inventory_count, adding that product again will no longer increment the quantity in the cart.
- removes the product once from the cart
- displays details of the cart
Example Cart format:
{
"items": {
"1": {
"title": "New Toy",
"price": 35.12,
"quantity": 11,
"itemPriceTotal": 386.32
},
"2": {
"title": "New New Toy",
"price": 35.11,
"quantity": 1,
"itemPriceTotal": 35.11
}
},
"totalPrice": "421.43"
}
- submits the current cart and updates the database accordingly
- Receives a JWT token for making requests to protected routes
POST Data Format:
{
"username": "testaccount",
"password": "password123"
}
- Adds a new product to the store
Example POST Data Format:
{
"title": "Awesome Crazy Toy",
"price": 23.99,
"inventory_count": 50
}
- Increase the product inventory_count by a given amount
Example POST Data Format:
{
"title": "Awesome Crazy Toy",
"add_amount": 10
}