cormacpujals / LettuceBe

https://lettuce-be.vercel.app
MIT License
0 stars 1 forks source link

[EPIC] APIs #10

Open subfuzion opened 1 year ago

subfuzion commented 1 year ago

users collection

user -> inventory -> item[]

{
  [
    {
      _id: 1,
      name: "Bob",
      inventory:
      [
        {
          product: 1,
          dateAdded: number
          dateExpires: number
        },
      ]
    },
  ]
}

products collection

category -> product[]

{
  [
    {
      _id: 1,
      name: "milk",
      category: "dairy",
      expires: number,  
    },
  ]
}

// - [x] GET /api/products - get FDA food products (src/pages/api/products.ts) // - [x] GET /api/categories - get FDA food product categories (ex: "dairy") (src/pages/api/categories.ts) Gets a collection of categories, each category will have an array of products in that category // - [x] GET /api/categories/[cat_id]/products - get FDA food products for a category

Admin APIs

cormacpujals commented 1 year ago

Do we need GET /api/categories and POST /api/categories?

If we have GET /api/products we can use .filter() to filter the products based on whether they contain the target category property.