๐Ÿง‘๐Ÿพโ€๐Ÿ’ป prep

CRUD Again

Learning Objectives

We are building a CRUD API. CRUD stands for Create, Retrieve, Update, Delete. If you think about it, this is what most applications do:

โœจ Create some “resources”
๐Ÿ• Retrieve them (GET them)
๐Ÿ“จ Update them
๐Ÿ—‘๏ธ Delete them

๐ŸŽฏ Goal

Our API will manage movie data. It will:

โœจ Create a new movie,
๐Ÿ• Retrieve a list of movies or a single movie
๐Ÿ“จ Update a movie

We will build this endpoint:

  1. PUT /movies/:movieId should update a movie (that matches the passed movieId)

๐Ÿ‘‰ You should already have a project using the Node-Starter-Kit. If not, do last week’s prep before you go on.

๐Ÿ“จ PUT

Learning Objectives

PUT /movies/:movieId should update a movie (that matches the passed movieId)

This means that PUT /movies/2 should update an movie with the id 2 and return 200 with JSON { success: true } to the user.

The code should look something like this:

app.put("/movies/:movieID", (req, res) => {
  console.log("PUT /movies route");
});

Remember, you have got to update the movie, not add it to the list.

Test that your API works by updating one of the movies.

๐Ÿ’ช๐Ÿพ CRUD Challenges

CHALLENGE 1:

Return the old version of the object you updated as well as the new value in the response

CHALLENGE 2:

Validate the request body to make sure the ID can’t be updated and that users can’t add additional fields

CHALLENGE 3:

Persist your changes to file so that you are able to return your updated values even after you restart the server

๐Ÿ“ฎ ๐Ÿงช Test Examples in Postman

Learning Objectives

You will need to create an account with Postman to complete this task. Follow along with the video Writing Tests in Postman with Examples.

๐Ÿ“ฎ Interactive Postman Workspace

activity

  1. Given a user wants to see all the movies, when they make a GET request to /movies, then they should receive a list of all the movies.

  2. Given a user wants to see a single movie, when they make a GET request to /movies/:movieId, then they should receive a single movie.

  3. Given a user wants to add a movie, when they make a POST request to /movies, then they should receive a success message.

  4. Given a user wants to update a movie, when they make a PUT request to /movies/:movieId, then they should receive a success message.

Prep Value and Work Not Done

Learning Objectives

Introduction

We donโ€™t have jobs just to fill the time. We should focus our efforts on delivering as much value as we can. You donโ€™t have to finish everything on your to-do list. Whenever you choose to do something, you implicitly choose not to do something else. Learn to identify some tasks that will deliver more value in your available time.

A typical project can be measured at several stages. The latter measures are closer to value, but these are harder to quantify:

  • Inputs โ†’ Effort โ†’ Outputs โ†’ Outcomes โ†’ Impact

Measuring Value

๐ŸŽฏ Goal: To read and learn about measuring value: its outputs, outcomes, and impact. (30 minutes)

Five Types of Value

๐ŸŽฏ Goal: To read and learn about different types of value. (30 minutes)