You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You were supposed to use req.params to implement this route.
Meal Sharing Website
Incomplete Requirements for Week 2
Most of the work here is for the requirements identified for Week 1's homework. For this week's work, you have only tried to implement the requirements for /meals and /meals/{id} routes.
The following routes are not implemented:
/reservations/{id}
/reviews
/reviews/{id}
Also, none of the logic you have implemented for the various query params on /meals route is reachable. Can you figure out what the problem is?
Unnecessary fs module in package.json
The fs module that you use in your homework in
is the core file system module in Node which does not need to be installed as a separate package in your package.json. You can read more about the fs module in Node documentation here: https://nodejs.org/api/fs.html
The package with the same name that you have installed here
is an empty placeholder package. You can safely remove it from your homework using npm uninstall fs.
Inconsistencies in files in data directory
In the meals.json file, the price of the first item is of the type number but all other prices are string values. Also, except for the first item, the createdAt property for all objects displays a SyntaxError instead of a useful value.
In the reservations.json file, all the email strings have spaces which would render them invalid.
Although these are not causing any problems in your homework, it's good to review the data that you use.
Implementation of Route /meal
The requirements for this route (for Week 1) were to Respond with the json for a random meal. If the meal has a reservation that matches its id, then add the email of that reservation to the json.
Although there's nothing wrong per se with the way you have implemented it, perhaps there's a more compact way to presenting this data. In case of meals for which multiple reservations are available, when one of them is selected as a random meal, the result in the browser looks like multiple meal objects are being sent, even though it's the same meal in each object and the only different property is the reservation email. Instead of creating multiple meal objects for each matching reservation, if all the matching reservations or the associated emails are stored as an array in a separate property on the meal object, it would probably be easier for the user to interpret the data. An example of this implementation would be something like this:
{
"id": 10,
"title": "kabab",
"maxNumberOfGuests": 19,
"description": "Amet ut voluptate ex consectetur proident. Magna proident eiusmod laborum do cupidatat dolor quis in quis in mollit esse officia. Qui aliqua pariatur laborum laborum non ut amet est eiusmod pariatur nulla ipsum dolore sint. Aliquip ullamco do mollit exercitation deserunt aliquip excepteur exercitation anim ex anim elit proident. Exercitation aliquip consectetur eiusmod ipsum id est dolore eu commodo occaecat ad excepteur id.",
"createdAt": "<SyntaxError: Unexpected identifier>",
"price": "100.67",
"mealReservations": [
{
"name": "Barry Whitaker",
"email": "barry [email protected]",
"mealId": 10
},
{
"name": "Cooke Hancock",
"email": "cooke [email protected]",
"mealId": 10
},
{
"name": "Everett Christensen",
"email": "everett [email protected]",
"mealId": 10
},
{
"name": "Lowe Albert",
"email": "lowe [email protected]",
"mealId": 10
}
]
}
Conclusion
Please implement the missing routes and debug the other problems highlighted above. If you need help with anything, please ask in the Slack channel for your class or let me know directly.
The text was updated successfully, but these errors were encountered:
Warmup Exercise
Please do not upload node_modules to your GitHub repo.
hyf-homework/nodejs/week2/warmup/index.js
Line 14 in 79b78a4
You were supposed to use
req.params
to implement this route.Meal Sharing Website
Incomplete Requirements for Week 2
Most of the work here is for the requirements identified for Week 1's homework. For this week's work, you have only tried to implement the requirements for
/meals
and/meals/{id}
routes.The following routes are not implemented:
/reservations/{id}
/reviews
/reviews/{id}
Also, none of the logic you have implemented for the various query params on
/meals
route is reachable. Can you figure out what the problem is?Unnecessary
fs
module inpackage.json
The
fs
module that you use in your homework inhyf-homework/nodejs/week2/mealSharingWebsite/src/backend/routes/randomMeal.js
Line 2 in 79b78a4
file system
module inNode
which does not need to be installed as a separate package in yourpackage.json
. You can read more about thefs
module in Node documentation here: https://nodejs.org/api/fs.htmlThe package with the same name that you have installed here
hyf-homework/nodejs/week2/mealSharingWebsite/package.json
Line 18 in 79b78a4
is an empty placeholder package. You can safely remove it from your homework using
npm uninstall fs
.Inconsistencies in files in data directory
In the
meals.json
file, the price of the first item is of the typenumber
but all other prices arestring
values. Also, except for the first item, thecreatedAt
property for all objects displays aSyntaxError
instead of a useful value.In the
reservations.json
file, all the email strings have spaces which would render them invalid.Although these are not causing any problems in your homework, it's good to review the data that you use.
Implementation of Route
/meal
The requirements for this route (for Week 1) were to
Respond with the json for a random meal. If the meal has a reservation that matches its id, then add the email of that reservation to the json
.hyf-homework/nodejs/week2/mealSharingWebsite/src/backend/routes/randomMeal.js
Line 15 in 79b78a4
Although there's nothing wrong per se with the way you have implemented it, perhaps there's a more compact way to presenting this data. In case of meals for which multiple reservations are available, when one of them is selected as a random meal, the result in the browser looks like multiple meal objects are being sent, even though it's the same meal in each object and the only different property is the reservation email. Instead of creating multiple meal objects for each matching reservation, if all the matching reservations or the associated emails are stored as an array in a separate property on the meal object, it would probably be easier for the user to interpret the data. An example of this implementation would be something like this:
Conclusion
Please implement the missing routes and debug the other problems highlighted above. If you need help with anything, please ask in the Slack channel for your class or let me know directly.
The text was updated successfully, but these errors were encountered: