Read: Class 07 : Express - Goorob-401-advanced-javascript/amman-javascript-401d1 GitHub Wiki

  • Express Routing :
  • Event driven system:
    • app.get('/thing', (req,res) => {})
    • This is the same pattern we see in Vanilla JS, jQuery
    • When a get event happens in our server, on “/thing”, run this function
  • The Request Object
    • (req,..)
    • /:parameters
      • app.get('/api/:thing',...) = req.params.thing
  • Query Strings
  • The Response Object -(..., res) -Responsible for sending data back to the browser Has methods like send() and status() that Express uses to format the output to the browser properly
    • Sends Headers
    • Cookies
    • Status Codes
  • Express Middleware
  • A series of functions that the request “goes through”
  • Each function receives request, response and next as parameters
  • Types of middleware: Application and Route
  • Application Middleware
  • Error Handling
  • Bringing in other routes
  • Applies Defaults
  • JSON, Body and Form Parsing
  • Runs on every request