A small toy backend built for browsing, adding & removing recipes. Intended for use in home assignments. Recipes are stored in a simple local json database.
Make sure you have nodejs and npm installed.
Install dependencies:
npm install
Start the backend:
npm start
The backend will be serving requests from localhost, port 3000. You can visit this link in your browser to verify that it is up and running correctly.
These are the available endpoints
GET localhost:3000/recipes- Returns the list of stored recipes
POST localhost:3000/recipes- Store a recipe in the backend
GET localhost:3000/recipes/:id- Retrieve a specific recipe
PUT localhost:3000/recipes/:id- Update a specific recipe
DELETE localhost:3000/recipes/:id- Delete a recipe
GET localhost:3000/reset- Development endpoint to reset the database to its original state
You can find them defined in endpoints.js.
This is the shape of a recipe:
interface Recipe {
title: string; // recipe title; REQUIRED
description: string; // short description of the recipe; REQUIRED
ingredients: string[]; // an array of strings for listing ingredients; REQUIRED
instructions: string; // instructions on how to prepare the food; REQUIRED
imageUrl?: string; // an URL to an image for the recipe; OPTIONAL
sourceUrl?: string; // an URL to the original recipe; OPTIONAL
}When creating new recipes by sending POST or PUT requests, the request body will be validated according to this model.
Sample recipes and and the schema validator can be found in recipes.js.
The recipes are stored locally in recipe-db.json. If you want to reset the
database to its original state use the reset endpoint above or visit
this link when the backend is running.