Welcome to lesson three! Having mastered GET requests, you will now learn how to add POST, PUT, and DELETE requests to your API. You will also learn several tools that will make your development more efficient and productive.
Resources for this lesson are accessible to you in this repository
As you learn about these different HTTP methods, know that there are always other ways to do things. For example, MongoDB uses queries and functions to insert, update, delete and retrieve data. Technically, I could use a POST to get data, modify it, or even delete it. However, these HTTP methods are here to add clarity and consistency to applications, and will work with other databases that don't rely on functions as much as MongoDB does.
Here is a great article that sums up the CRUD (Create, Read, Update, Delete) process using Node.js and MongoDB.
Once you learn how to use code linters, you should never go back. When properly configured, they help keep your code, neat, clean, functional, and error-free. You should use a linter on your code for the remainder of this class.
Once you learn how to use code formatters, you should never go back. When properly configured, they help keep your code neat, consistent and clean. You should use a formatter on your code for the remainder of this class.
The following article shows how to set up a linter and formatter with your project. Ignore the React stuff this time around and be sure to select Node instead of Browser when it prompts for where your code will run.
Once this is all set up, you can run commands from the terminal like: "npm run lint" or the others that we put into the package.json.
Purpose: Research, learn, and share industry standards, best practices, and helpful resources.
Task: Complete the assignment.
The team activity for this lesson will consist of participating in a developer forum. Each person in this class will learn from different resources, try different things, and end up with a unique knowledge base. This forum is an opportunity for you to share industry standards and best practices regarding the technologies that we are using and that you're learning about in this lesson. To receive full credit for this assignment, you must do the following:
Developer Forum for this assignment.L03 - POST requests in Node.js)Purpose: Perform GET, POST, PUT, and DELETE requests in an API connected to a database.
Task: Complete the assignment.
By the end of this assignment the student will be able to do the following:
For this assignment, you will continue to work on your project from the previous two lessons. You have already create a MongoDB cluster with a contacts collection along with a node.js project with several GET requests to retrieve different pieces of data from your database. This lesson, you will add a few more routes to your Node.js project to add POST, PUT, and DELETE requests to your API.
| Criteria | Weight | Mastery | Proficient | Developing | Beginning | Missing/Incomplete |
|---|---|---|---|---|---|---|
| 100% | 90% | 78% | 65% | 0% | ||
Render Connects to MongoDB(Graded via YouTube) | 30% | Meets Proficient criteria and video shows sensitive database information is stored securely in Render Config Vars (not pushed to GitHub) | Meets Developing criteria and Render application successfully reads data from MongoDB | Meets Beginning criteria and Render application successfully connects to MongoDB | Render url is submitted & MongoDB attempt is shown in video | Render link or YouTube link not submitted or no evidence of MongoDB |
New Contact(Graded via YouTube) | 15% | Meets Proficient criteria plus POST returns the id of newly created contact and status of 201 | Meets Developing criteria plus video shows that the POST route creates a new contact in MongoDB | Meets Beginning criteria plus code is present to accept a request body | Node.js project shows code for the POST route to create a contact | Render link, GitHub link, or YouTube link not submitted. Or no MongoDB reference. |
Update Contact(Graded via YouTube) | 15% | Meets Proficient criteria plus PUT returns response with status of 204 | Meets Developing criteria plus video shows that the PUT route updates a contact in MongoDB | Meets Beginning criteria plus code is present for PUT route to update a contact by their id | Node.js project shows code for the PUT route to update a contact | Render link, GitHub link, or YouTube link not submitted. Or no MongoDB reference. |
Delete Contact(Graded via YouTube) | 15% | Meets Proficient criteria plus DELETE returns response with status of 200 | Meets Developing criteria plus no errors are present and video shows that the DELETE route deletes a contact in MongoDB | Meets Beginning criteria plus code is present for DELETE route to delete a contact by their id | Node.js project shows code for the DELETE route to delete a contact | Render link, GitHub link, or YouTube link not submitted. Or no MongoDB reference. |
Architecture(Graded via GitHub) | 15% | Meets Proficient criteria plus includes a .rest file with routes for localhost and Render | Meets Developing criteria plus each route calls a function imported from a controller | Meets Beginning criteria plus server connects to routes in project "routes" folder using only a single line of code | Server file is present in root folder (server.js, index.js or app.js) to run the Node project | Render link not submitted |
Endpoint Testing(Graded via GitHub) | 10% | Meets Proficient criteria and .rest file has GET, POST, PUT and DELETE routes for Render and Localhost | Meets Developing criteria and .rest file has at least three Render routes | Meets Beginning criteria and .rest file has at least three localhost routes | Node project has .rest file | No submission, no .rest file, or no attempt made |