The company stakeholders want to create an online storefront to showcase their great product ideas. Users need to be able to browse an index of all products, see the specifics of a single product, and add products to an order that they can view in a cart page. You have been tasked with building the API that will support this application, and your coworker is building the frontend.
These are the notes from a meeting with the frontend developer that describe what endpoints the API needs to supply, as well as data shapes the frontend and backend have agreed meet the requirements of the application.
- Index
/products[GET] - Create
/products/create[POST] [token required] - Read
/products/:id[GET] - Update
/products/:id[PUT] [token required] - Delete
/products/:id[DELETE] [token required]
- Index
/users[GET] [token required] - Create
/users/create[POST] - Read
/users/:id[GET] [token required] - Update
/users/:id[PUT] [token required] - Delete
/users/:id[DELETE] [token required] - Auth
/users/auth[POST]
- Index
/orders[GET] [token required] - Create
/orders/create[POST] [token required] - Read
/orders/:id[GET] [token required] - Update
/orders/:id[PUT] [token required] - Delete
/orders/:id[DELETE] [token required]
Table: products
- id
SERIAL PRIMARY KEY - name
VARCHAR - price
INTEGER
Table: users
- id
SERIAL PRIMARY KEY - username
VARCHAR - firstname
VARCHAR - lastname
VARCHAR - password_digest
VARCHAR
Table: orders
- id
SERIAL PRIMARY KEY - user_id
INTEGERREFERENCES users(id) - status
BOOLEAN
Table: order_products
- order_id
INTEGERREFERENCES orders(id) - product_id
INTEGERREFERENCES products(id) - quantity
INTEGER