/w02d03

Lecture notes and example app

Primary LanguageHTML

W02D03 CRUD with Express

To Do

  • Implement CRUD/BREAD over HTTP with Express
  • Use forms to submit HTTP requests
  • Practice debugging Express

Express

A framework that lets us create routes and write/include middleware.

CRUD / BREAD

CRUD = Create Read Update Delete

BREAD = Browse Read Edit Add Delete

Routes

A route is made up of a VERB and a PATH.

Verbs: GET, POST, PUT, PATCH, DELETE

Path: example.com/resource, example.com/resource/:id

REST - REpresentational State Transfer

REST means that the path that we are going to should represent the data being transferred.

An API that uses the REST convention is said to be RESTful.

RESTful routes look like:

  • Browse: GET /resource
  • Read: GET /resource/:id
  • Edit: POST /resource/:id
  • Add: POST /resource
  • Delete: POST /resource/:id/delete

GET /unicorns/123

GET /users/123/posts/12

B - GET /dogs

R - GET /dogs/:id

E - POST /dogs/:id

A - POST /dogs | GET /dogs/new

D - POST /dogs/:id/delete

Useful Links

Inspired by Sadie Freeman's lecture on the same topic