Skip to content

Latest commit

 

History

History
122 lines (74 loc) · 3.13 KB

README.md

File metadata and controls

122 lines (74 loc) · 3.13 KB

HackYourFuture Node.js Week 3

Agenda

  1. Recap last Week
  2. Previous homework
  3. Questions & answers (Q&A)
  4. Testing with Postman
  5. Express.js vs native http library
    1. HTTP request method refresher
    2. HTTP response status code refresher
    3. Routing
    4. Example
  6. Building a REST API for To-Dos
  7. Homework

Last week's summary

Last week we made a CLI To-Do application. This week we are going to rewrite it into an Express-based server.

Testing with Postman

Download and install Postman.

Videos:

Getting Started with Postman

Express.js vs native http library

Videos:

Introduction to Express

Express Route Params

Middleware & Static Files

Documentation:

Express.js Hello World

Express.js routing

Express.js API

HTTP request methods

HTTP response status codes

Building a REST API for To-Dos

Videos:

What is REST?

Documentation:

REST

Learn REST: A RESTful Tutorial

To-Do API

This week we are going to write an Express application with request body in JSON format.

There are 4 CRUD actions:

createTodo (POST /todos)

Creates a new to-do

readTodos (GET /todos)

Reads and lists all to-dos

updateTodo (PUT /todos/:id)

Updates the description of a to-do with ID :id

deleteTodo (DELETE /todos/:id)

Deletes a to-do with ID :id

Request Body Format

When calling the create or update actions, the request body must look like this:

{
  "todo": {
    "description": "(todo description)"
  }
}

Note that for these actions, the client must add the following header:

  • Content-Type: application/json

In Postman, make sure to add this header, and set the Body type to raw and JSON (application/json).

UUIDs

For IDs, this application uses UUIDs - Universally Unique IDs. They can be generated using the uuid/v4 package, and are guaranteed never to be the same.

Homework

Check README.md in homework subdirectory.

Prepare for the next module

Check out the databases repository and find out how you can prepare for the first database lecture, Jason and Rob have provided a nice Lynda playlist so we can have a flying kick off.