Lesson 3: HTTP Requests & Dev Tools

  Overview

Introduction

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.

Topics for this lesson:

  • URI Hierarchies
  • HTTP POST
  • HTTP PUT
  • HTTP DELETE
  • MongoDB CRUD
  • Linters
  • Code Formatters
Have Feedback?

  Learning Material

Resources for this lesson are accessible to you in this repository

The following learning material may be helpful but is not required. Please reference the syllabus for more details.

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.

  Team Assignment

Overview

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:

  Personal Assignment

Overview

Purpose: Perform GET, POST, PUT, and DELETE requests in an API connected to a database.
Task: Complete the assignment.

Learning Objectives

By the end of this assignment the student will be able to do the following:

Assignment Description

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.

Rubric

CriteriaWeightMasteryProficientDevelopingBeginningMissing/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 MongoDBMeets Beginning criteria and Render application successfully connects to MongoDBRender url is submitted & MongoDB attempt is shown in videoRender 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 201Meets Developing criteria plus video shows that the POST route creates a new contact in MongoDBMeets Beginning criteria plus code is present to accept a request bodyNode.js project shows code for the POST route to create a contactRender 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 204Meets Developing criteria plus video shows that the PUT route updates a contact in MongoDBMeets Beginning criteria plus code is present for PUT route to update a contact by their idNode.js project shows code for the PUT route to update a contactRender 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 200Meets Developing criteria plus no errors are present and video shows that the DELETE route deletes a contact in MongoDBMeets Beginning criteria plus code is present for DELETE route to delete a contact by their idNode.js project shows code for the DELETE route to delete a contactRender 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 RenderMeets Developing criteria plus each route calls a function imported from a controllerMeets Beginning criteria plus server connects to routes in project "routes" folder using only a single line of codeServer file is present in root folder (server.js, index.js or app.js) to run the Node projectRender 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 LocalhostMeets Developing criteria and .rest file has at least three Render routesMeets Beginning criteria and .rest file has at least three localhost routesNode project has .rest fileNo submission, no .rest file, or no attempt made