CS546 – Lab 7 (Solution)

$ 24.99
Category:

Description

CS­546 Lab 7
A Recipe API
For this lab, you will create a simple server that provides an API for someone to Create, Read, Update, and Delete recipes. These recipes will be stored in a database named lab7­recipes.
This recipe database will also provide support for creating, reading, updating, and deleting comments for a recipe.
The recipe object

For example, a fried egg recipe:

Comments

Your comment will be stored on the recipe page.

For example:

verb path description
GET /recipes
Responds with a list of all recipes in the format of {_id: RECIPE_ID, title: RECIPE_TITLE}
GET /recipes/:id
Responds with the full content of the specified recipe
POST /recipes
Creates a recipe with the supplied data in the request body, and returns the new recipe
PUT /recipes/:id
Updates the specified recipe with only the supplied changes, and returns the updated recipe
DELETE /recipes/:id
Deletes the recipe
GET /comments/recipe/:recipeId
Returns a list of all comments in the specified recipe, in the format of:
{_id: COMMENT_ID, recipeId: RECIPE_ID, recipeTitle: RECIPE_TITLE, poster: COMMENT_NAME, comment: COMMENT}
GET /comments/:commentId
Returns the comment specified by that commentId in the format of
{_id: COMMENT_ID, recipeId: RECIPE_ID, reciipeTitle: RECIPE_TITLE, poster: COMMENT_NAME, comment: COMMENT}
POST /comments/:recipeId/
Creates a new comment with the supplied data in the request body for the stated recipe, and returns the new comment
PUT /comments/:recipeId/:commentId
Updates the specified comment for the stated recipe with only the supplied changes, and returns the updated comment
DELETE /comments/:id
Deletes the comment specified
Packages you will use:

You will use the express package as your server.
You will use the node­uuid package in order to generate unique id’s to use as your identifiers.
You can read up on node­uuid (https://github.com/broofa/node­uuid) on the Github project page.
You will also use the mongodb (http://mongodb.github.io/node­mongodb­native/2.1/) package.
Your Routes
Any issues should result in a properly failed status code and a description of the error in JSON.
Requirements

1. You must not submit your node_modules folder
2. You must remember to save your dependencies to your package.json folder
3. You must do basic error checking in each function 1. Check for arguments existing and of proper type.
2. Throw if anything is out of bounds (ie, trying to perform an incalculable math operation or accessing data that does not exist)
3. If a function should return a promise, instead of throwing you should return a rejected promise.
4. You must remember to update your package.json file to set app.js as your starting script!

Reviews

There are no reviews yet.

Be the first to review “CS546 – Lab 7 (Solution)”

Your email address will not be published. Required fields are marked *