The program is a multi-user web service based on Spring Boot that allows storing, retrieving, updating, and deleting recipes.
- POST /api/register receives a JSON object with two fields: email (string), and password (string). Both fields are required and must be valid: email should contain @ and . symbols, password should contain at least 8 characters and shouldn't be blank.
- POST /api/recipe/new receives a recipe as a JSON object and returns a JSON object with one id field. This is a uniquely generated number by which we can identify and retrieve a recipe later. All fields are required, string fields can't be blank, arrays should have at least one item.
- PUT /api/recipe/{id} receives a recipe as a JSON object and updates a recipe with a specified id. Also, update the date field too. All fields are required, string fields can't be blank, arrays should have at least one item).
- GET /api/recipe returns all recipes as a JSON object.
- GET /api/recipe/{id} returns a recipe with a specified id as a JSON object.
- GET /api/recipe/search takes one of the two mutually exclusive query parameters:
- category – if this parameter is specified, it returns a JSON array of all recipes of the specified category. Search is case-insensitive, sort the recipes by date (newer first).
- name – if this parameter is specified, it returns a JSON array of all recipes with the names that contain the specified parameter. Search is case-insensitive, sort the recipes by date (newer first).
- DELETE /api/recipe/{id} deletes a recipe with a specified id.
POST /api/register
{
"email": "[email protected]",
"password": "RecipeInBinary"
}
POST /api/recipe/new
{
"name": "Fresh Mint Tea",
"category": "beverage",
"description": "Light, aromatic and refreshing beverage, ...",
"ingredients": ["boiled water",
"honey",
"fresh mint leaves"],
"directions": ["Boil water",
"Pour boiling hot water into a mug",
"Add fresh mint leaves",
"Mix and let the mint leaves seep for 3-5 minutes",
"Add honey and mix again"]
}
PUT /api/recipe/1
{
"name": "Warming Ginger Tea",
"category": "beverage",
"description": "Ginger tea is a warming drink for cool weather, ...",
"ingredients": ["1 inch ginger root, minced",
"1/2 lemon, juiced",
"1/2 teaspoon manuka honey"],
"directions": ["Place all ingredients in a mug and fill with warm water (not too hot so you keep the beneficial honey compounds in tact)",
"Steep for 5-10 minutes",
"Drink and enjoy"]
}