Skip to content

Backend Routes

chen445 edited this page May 27, 2021 · 1 revision

HTML

  • GET / StaticPagesController#root

API Endpoints

users

  • GET /api/users - find all users. User info are used in displaying current logged in user gmail, resolving sellers' names for products, and resolving reviewers' name.
  • POST /api/users - It creates a new user with gmail, password and name.

products

  • GET /api/products - It expects a parameter called search_query. When it is empty, returns all products. Otherwise we return products that contains the search_query.
  • GET /api/products/:id - It returns details of a product.

reviews

  • GET /api/products/:product_id/reviews - It returns all reviews for the particular product with the ID.
  • POST /api/products/:product_id/reviews - It creates a review for the product with product_id.
  • PATCH /api/products/:product_id/reviews/:id - It modifies an existing review for the product with product_id.
  • DELETE /api/products/:product_id/reviews/:id - It deletes a review by ID.

carts

  • GET /api/carts - It returns all cart items belongs to the current user.
  • DELETE /api/carts/:id - It deletes an item in the cart.
  • POST /api/carts/:id - It create a new item in the cart for a product.

session

  • POST /api/session - User login
  • DELETE /api/session - User logout

Clone this wiki locally