Code Monkey home page Code Monkey logo

node-basic-2's Introduction

Express Recipes Filter

The request to the route /recipes/shopping-list?ids returns a list of all the aggregated ingredients contained in the matching IDs. The query parameter that can be used to set the recipe id is:

  • ids: A comma-separated list of IDs for which the ingredients have to be aggregated. [STRING]

Note: The ingredients should only be aggregated for the IDs that match any of the recipe IDs present in the Recipe list, which is contained in the recipes.json file. All the non-matching IDs can be ignored entirely from the response.

Each Recipe object has a list of ingredients stored in the ingredients property of the object, as can be seen here:

{
    "id" : 1,
    "name": "Pot Roast",
    "ingredients": [
        {
            "quantity": "1",
            "name": " beef roast",
            "type": "Meat"
        },
        {
            "quantity": "1 package",
            "name": "brown gravy mix",
            "type": "Baking"
        }
    ]
}

Routes

  • /recipes/shopping-list?ids - The route to fetch all the aggregated ingredients for the matching recipes. The query parameter ids is mandatory, and the server should send a status code 400 if the query parameter ids is blank or not present. If none of the IDs passed match with the IDs present in the data-store, the server should send a status code 404 with NOT_FOUND in the body of the response.

Examples

  • /recipes/shopping-list
Response

Status Code - 400
  • /recipes/shopping-list?ids=asdasd
Response

Status Code - 404
Body - NOT_FOUND
  • /recipes/shopping-list?ids=3
[
  {
    "quantity":"1 quart",
    "name":"beef broth",
    "type":"Misc"
  },
  {
    "quantity":"1 cup",
    "name":"dried green lentils",
    "type":"Misc"
  }
]

Project Specifications

Read-Only Paths

  • test
  • bin
  • recipes.json

Commands

  • run: npm start
  • install: npm install
  • test: npm test

node-basic-2's People

Contributors

m0107 avatar

Watchers

 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.