/recipe-server

Companion to "Cooking with SwiftUI".

Primary LanguageJavaScript

recipe-server

A simple static JSON server to return recipe information.

API Endpoints

Description Fetch a list of all recipe pointers
Method GET
Endpoint /recipes
Parameters None.
Example URL http://localhost:3000/recipes
Example Response
{
  "recipes": [
    {
      "id": "mamas_meatballs",
       "name": "Mama's Meatballs"
    }
  ]
}

Description Fetch a full recipe
Method GET
Endpoint /recipes/:id
Parameters id - string - the unique id for the recipe.
Example URL http://localhost:3000/recipes/mamas_meatballs
Example Response
{
  "recipe": {
    "name": "Mama's Meatballs",
    "image": "https://images.unsplash.com/photo-1586955080976-3854194bf139",
    "ingredients": [
      {
        "id": "frozen_meatballs",
        "name": "frozen meatballs",
        "amount": 6.5,
        "unit": {
          "name": "ball",
          "pluralName": "balls"
        }
      },
      {
        "id": "parmesan_cheese",
        "name": "parmesan cheese",
        "amount": 1,
        "unit": {
          "name": "tablespoon",
          "pluralName": "tablespoons",
          "metricName": "milliliter",
          "metricPluralName": "milliliters",
          "metricConversionFactor": 14.8
        }
      },
      {
        "id": "love",
        "name": "love",
        "amount": 1,
        "unit": {
          "name": "pinch",
          "pluralName": "pinches"
        }
      }
    ],
    "steps": [
      "Add frozen meatballs to plate.",
      "Place in microwave for 3 minutes.",
      "Sprinkle parmesan cheese on top.",
      "Enjoy!"
    ]
  }
}

Description Fetch a list of all ingredients
Method GET
Endpoint /ingredients
Parameters None.
Example URL http://localhost:3000/ingredients
Example Response
{
  "ingredients": [
    {
      "id": "frozen_meatballs",
      "name": "frozen meatballs"
    },
    {
      "id": "parmesan_cheese",
      "name": "parmesan cheese"
    },
    {
      "id": "love",
      "name": "love"
    }
  ]
}

Description Fetch a list of all recipe pointers with a matching ingredient
Method GET
Endpoint /ingredients/:id
Parameters id - string - the unique id for the ingredient.
Example URL http://localhost:3000/ingredients/love
Example Response
{
  "recipes": [
    {
      "id": "mamas_meatballs",
      "name": "Mama's Meatballs"
    }
  ]
}

Description Search for recipes and ingredients with matching names
Method GET
Endpoint /search?query=:query
Parameters query - string - the search query to match recipes and ingredients by.
Example URL http://localhost:3000/search?query=meatballs
Example Response
{
  "recipes": [
    {
      "id": "mamas_meatballs",
      "name": "Mama's Meatballs"
    }
  ],
  "ingredients": [
    {
      "id": "frozen_meatballs",
      "name": "frozen meatballs"
    }
  ]
}