Coder Social home page Coder Social logo

qs-backend's Introduction

QS BackEnd

This is an internal API which was built with the purpose to provide a backend behind the QS FrontEnd Calorie Tracker app.
There has been a special focus on creating RESTful routes for CRUD functionality of both the foods-list and meal-diary functionality of the QS FrontEnd.

This API provides the following endpoints:

  • GET /api/foods: returns all items from the Foods List. The return value is an array of food objects in JSON
    Example:
    Request: GET /api/foods
    Response:
    HTTP code: 200
    {[
      {
        id: 1111111,
        name: 'FoodName1',
        calories: '111'
      },
      {
        id: 222222,
        name: 'FoodName2',
        calories: '222'
      }
    ]}
    
  • GET /api/foods/:id: returns details of a single food item with id. The id is a unique number generated when the new food item is created. When there is no food item with the requested id, an HTTP status 404 will be returned. Example:
    Request: GET /api/foods/9876543210
    Response:
    HTTP status: 200
    {
      id: 9876543210,
      name: 'FooodName',
      calories: '123'
    }
    
  • POST /api/foods: adds a food item to the foods list. It returns a copy of the entire foods item object upon successfully adding the new food item to the foods list. If the request is incomplete, it returns a 402 HTTP status along with a JSON formatted error message. Example:
    Complete input request:
    {
      name: 'FoodName',
      calories: '123'
    }
    
    Return value when submission was successful:
    HTTP status: 200
    {
      id: 9876543210,
      name: 'FoodName',
      calories: '123'
    }
    
    Return value when submission details were incomplete (name and/or calories missing):
    HTTP status: 402
    {
      status: 402,
      details: 'Food detail missing'
    }
    
  • PUT /api/foods/:id: update the details of the selected food item with id. All food details (name, calories) have to sent. There is no logic implemented on the BackEnd side to try to find out one or both of the values need to be updated. Once the food item is updated, it will return an HTTP status 200 and readout of the updated updated food item object as a JSON.
    Example:
    Request: PUT /api/foods/9876543210 with the following food details submitted:
    {
      name: 'UpdatedName',
      calories: 'SameCalories'
    }
    
    Response:
    HTTP status: 200
    {
      id: 9876543210,
      name: 'UpdatedName',
      calories: 'SameCalories'
    }
    

qs-backend's People

Contributors

laszlo-jflmtco avatar

Watchers

James Cloos avatar  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.