Zoomea / meal-planning-app

1 stars 0 forks source link

API: save recipe to dabatase #2

Open Zoomea opened 8 months ago

Zoomea commented 8 months ago

When user fills in the form and click save, should add the recipe information to the database.

Screenshot 2024-03-02 at 5 33 12 pm

This might also be used when user updates the recipe.

wlcsm commented 8 months ago

Do we want to add the cooking instructions as well?

Here is a draft API. Does this look good to you?

POST /api/recipe

Provide in JSON body

{
  "name":  "Example Recipe",
  "description": "Example description",
  "prepTimeMins": 70, # meaning 1hr 10min preparation time
  "cookTimeMins": 90, # meaning its 1hr 30min cooking time
  "difficulty": 3,
  "ingredients": [
    {
       "name": "cumin",
       "quantity": 10,
       "unit": "grams"
    },
     {
       "name": "tomato",
       "quantity": 2,
       "unit": ""  # Omit if no unit of measurement is required
    },
  ]
}

It will then return

{
  "data": 5, # the id of the recipe that has been created
  "error": ""
}

The full information of the recipe can then be obtained by calling GET /api/recipe/5