-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
49 lines (35 loc) · 2.83 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>QuantifiedSelfApi</title>
<link rel="stylesheet" media="all" href="styles/main.css">
</head>
<body>
<div class="container">
<h1>Welcome to Turing School's Quantified Self API - EXPRESS </h1>
<div class="instructions">
<p>The following endpoints are available. All endpoints will return the data as JSON.</p>
<div class="api">
<p>Food Endpoints:</p>
<ul>
<li><code>GET /api/v1/foods</code> - returns all foods currently in the database</li>
<li><code>GET /api/v1/foods/:id</code> - returns the food object with the specific <code>:id</code> you've passed in or 404 if the food is not found</li>
<li><code>POST /api/v1/foods</code> - allows creating a new food with the parameters: <br><code>{ food: { name: "Name of food here", calories: "Calories here"} }</code><br> If food is successfully created, the food item will be returned. If the food is not successfully created, a 400 status code will be returned. Both name and calories are required fields.</li>
<li><code>PATCH /api/v1/foods/:id</code> - allows one to update an existing food with the parameters:<br> <code>{ food: { name: "Name of food here", calories: "Calories here"} }</code><br> If food is successfully updated (name and calories are required fields), the food item will be returned. If the food is not successfully updated, a 400 status code will be returned.</li>
<li><code>DELETE /api/v1/foods/:id</code> - will delete the food with the id passed in. If the food can't be found, a 404 will be returned.</li>
</ul>
</div>
<div class="api">
<p>Meal Endpoints:</p>
<ul>
<li><code>GET /api/v1/meals</code> - returns all the meals in the database along with their associated foods</li>
<li><code>GET /api/v1/meals/:meal_id/foods</code> - returns all the foods associated with the meal with an id specified by <code>:meal_id</code> or a 404 if the meal is not found</li>
<li><code>POST /api/v1/meals/:meal_id/foods/:id</code> - adds the food with <code>:id</code> to the meal with <code>:meal_id</code><br>This creates a new record in the MealFoods table to establish the relationship between this food and meal. If the meal/food cannot be found, a 404 will be returned.
</li><li><code>DELETE /api/v1/meals/:meal_id/foods/:id</code> - removes the food with <code>:id</code> from the meal with <code>:meal_id</code><br>This deletes the existing record in the MealFoods table that creates the relationship between this food and meal. If the meal/food cannot be found, a 404 will be returned.
</li></ul>
</div>
</div>
</div>
</body>
</html>