Skip to content

Latest commit

 

History

History
82 lines (55 loc) · 3.4 KB

REQUIREMENTS.md

File metadata and controls

82 lines (55 loc) · 3.4 KB

API Requirements

API Endpoints

Users

METHOD ENDPOINT REQUEST BODY & PARAMS RESPONSE
GET http://localhost:3001/api/users List of all users
GET http://localhost:3001/api/users/:id id of the user && NEED AUTH List Single user
POST http://localhost:3001/api/users/ {email, userName, firstName, lastName, password} && NEED AUTH Created user
POST http://localhost:3001/api/users/login { email, password } Authenticated User

Products

METHOD ENDPOINT REQUEST BODY & PARAMS RESPONSE
GET http://localhost:3001/api/products/ List of all products
GET http://localhost:3001/api/products/:id id of the product List Single product
POST http://localhost:3001/api/products/ NEED AUTH && { name, prcie, category } Created product

Orders

METHOD ENDPOINT REQUEST BODY & PARAMS RESPONSE
GET http://localhost:3001/api/orders/1/find NEED AUTH && user id List of all orders for the user
POST http://localhost:3001/api/orders/1/create NEED AUTH && user id Created order
POST http://localhost:3001/api/orders/1/create-product NEED AUTH && user id && { order_id, product_id, product_quantity } Added product order record

D Shapes

Products

  • id
  • name
  • price
  • category

Users

  • id
  • firstName
  • lastName
  • password

Orders

  • id
  • id of each product in the order
  • quantity of each product in the order
  • user_id
  • status of order (active or complete)

Database Schema

Users Table

id email fisrtname lastname password
` id SERIAL PRIMARY KEY, email VARCHAR(255) UNIQUE, firstName VARCHAR(100), lastName VARCHAR(100), password VARCHAR(255) `

Products Table

id name price category
` id SERIAL PRIMARY KEY, name VARCHAR(255) NOT NULL, price integer NOT NULL, category VARCHAR(255) `

Orders Table

id user_id order_status
` id SERIAL PRIMARY KEY, user_id bigint REFERENCES users(id), order_status VARCHAR(15) DEFAULT 'active'`

Orders_products Table

id order_id product_id product_quantity
` id SERIAL PRIMARY KEY, order_id bigint REFERENCES orders(id), product_id bigint REFERENCES products(id), product_quantity integer`