Giter VIP home page Giter VIP logo

quantified-self's Introduction

Quantified Self

Team Members: Brett Schwartz and Seth Moser

API Endpoints

Food CRUD

List of All Foods

GET /api/foods

Returns index of all active foods:

[
    {
        "id": 1,
        "name": "Apple",
        "calories": 90,
        "created_at": "2017-07-09T22:39:37.799Z",
    },
    {
        "id": 2,
        "name": "Pear",
        "calories": 105,
        "created_at": "2017-07-09T22:39:37.799Z",
    },
    {
        "id": 3,
        "name": "Banana",
        "calories": 300,
        "created_at": "2017-07-09T22:39:37.799Z",
    }
]

Show Particular Food

GET /api/foods/:id

Returns details for a single food item:

{
    "id": 1,
    "name": "Orange",
    "calories": 90,
    "created_at": "2017-07-09T22:39:37.799Z",
}

Create a New Food

POST /api/foods?name=[]&calories=[]

Will create a new food and return the food:

    {
        "id": 1,
        "name": "Orange",
        "calories": 90,
        "created_at": "2017-07-09T22:39:37.799Z",
        "status": "active"
    },

Update an Existing Food

PUT /api/foods/:id?name=[]&calories=[]

Will update an existing food and return the updated food:

    {
        "id": 1,
        "name": "Orange",
        "calories": 90,
        "created_at": "2017-07-09T22:39:37.799Z",
        "status": "active"
    }

Delete a Food

DELETE /api/foods/:id

Will 'inactivate' an existing food by its id and return the current index with all foods:

[
    {
        "id": 1,
        "name": "Orange",
        "calories": 90,
        "created_at": "2017-07-09T22:39:37.799Z",
        "status": "active"
    },
    {
        "id": 2,
        "name": "Banana",
        "calories": 105,
        "created_at": "2017-07-09T22:39:37.799Z",
        "status": "active"
    },
    {
        "id": 3,
        "name": "Pear",
        "calories": 300,
        "created_at": "2017-07-09T22:39:37.799Z",
        "status": "active"
    }
]

Updating Diary

List All Foods for a Meal

GET /api/meals/:id

Returns an array of food items for a particular meal by the meal's id:

[
    {
        "id": 7,
        "name": "Pizza",
        "calories": 300,
        "created_at": "2017-07-09T22:39:37.736Z",
        "status": "active",
        "food_id": 1,
        "meal_id": 3
    },
    {
        "id": 8,
        "name": "Pretzels",
        "calories": 150,
        "created_at": "2017-07-09T22:39:37.736Z",
        "status": "active",
        "food_id": 2,
        "meal_id": 3
    }
]

Meal IDs:

  • 1 = Breakfast
  • 2 = Lunch
  • 3 = Dinner
  • 4 = Snacks

Add Food to Meal

POST /api/food_meals?food_id=[]&meal_id=[]

Adds a food to a meal by creating a new joins item (food_meal) and returns an array of that meal's current list of foods:

[
    {
        "id": 7,
        "name": "Pizza",
        "calories": 300,
        "created_at": "2017-07-09T22:39:37.736Z",
        "status": "active",
        "food_id": 1,
        "meal_id": 3
    },
    {
        "id": 8,
        "name": "Pretzels",
        "calories": 150,
        "created_at": "2017-07-09T22:39:37.736Z",
        "status": "active",
        "food_id": 2,
        "meal_id": 3
    },
    {
        "id": 9,
        "name": "Root Beer",
        "calories": 150,
        "created_at": "2017-07-09T22:39:37.736Z",
        "status": "active",
        "food_id": 3,
        "meal_id": 3
    }
]

Remove Food from Meal

DELETE /api/food_meals/:id

Will remove the food from that meal by the food_meal id and returns an array of that meal's current list of foods:

[
    {
        "id": 8,
        "name": "Pretzels",
        "calories": 150,
        "created_at": "2017-07-09T22:39:37.736Z",
        "status": "active",
        "food_id": 2,
        "meal_id": 3
    },
    {
        "id": 9,
        "name": "Root Beer",
        "calories": 150,
        "created_at": "2017-07-09T22:39:37.736Z",
        "status": "active",
        "food_id": 3,
        "meal_id": 3
    }
]

quantified-self's People

Contributors

bschwartz10 avatar seth-at-at avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.