Database Schema and Backend Routes - fangruz114/Lizuvia GitHub Wiki
Database Schema
Backend Routes
Sessions
GET /api/auth/
- Returns the information for the logged in user
POST /api/auth/signup
- Signs a new user up
POST /api/auth/login
- Logs in a user
DELETE /api/auth/
- Logs out a user
Products
GET /api/products
- Return all products
GET /api/products/categories/:category
- Return all products in a specific category
GET /api/products/:id
- Return the product details by product ID
POST /api/products
- add a new product by current user
PUT /api/products/:id
- edit a product listed by current user
DELETE /api/products/:id
- delete a product
Orders
GET /api/orders
- Return all orders placed by current user
GET /api/orders/:id
- Return order details for a specific order
POST /api/orders
- Checkout and create a order
DELETE /api/cart
- empty current user's shopping cart
- create an order and empty the shopping cart happen at the same time.
PUT /api/orders/:id
- edit order details (edit products qty or remove product)
DELETE /api/orders/:id
- cancel an order placed by current user not more than 5 hours ago
GET /api/cart
- Return all products in current user's shopping cart
POST /api/cart/products/:id
- Add a product to current user's shopping cart
PUT /api/cart/:id
- edit the quantity of a product in current user's shopping cart
DELETE /api/cart/products/:id
- remove a product from current user's shopping cart
Reviews
GET /api/products/:id/reviews
- return all reviews for a specific product
POST /api/products/:id/reviews
- create a review for a specific product
PUT /api/reviews/:id
- edit and update a review
DELETE /api/reviews/:id
- delete a review wrote by current user
Search and Sort
GET /api/products/search?:params
- return products whose name, description or bullet points includes the search keywords
- return products that sorted by "New Arrivals"
- return products that sorted by "Prices, low to high"
- return products that sorted by "Prices, high to low"