Skip to content

Instantly share code, notes, and snippets.

@nrl240
Last active March 11, 2021 15:21
Show Gist options
  • Save nrl240/740444254da849a30878c5cce00f09f1 to your computer and use it in GitHub Desktop.
Save nrl240/740444254da849a30878c5cce00f09f1 to your computer and use it in GitHub Desktop.
Exit Ticket: Day 8 - Node-Postgres pg, Express Routing, RESTful API

Exit Ticket: Day 8 - Node-Postgres pg, Express Routing, RESTful API

You should be able to:

  • Describe the role of pg in our stack
  • Define REST and its advantages
  • Create and mount Express Routers
  • Explain the role of body parsing middleware

What role does node-postgres (pg) assume when communicating with Postgres?

  • Client ☑️
  • Server
  • Neither

Remember, the client role is assumed by "who" initiates the request. In this case, our Node application is requesting data from our Postgres database. Our Postgres database, completes this communication by sending a response.

What is REST?

  • A node module for handling routes
    • Express
  • A type of built-in express middleware for designing routers
    • Express Router
  • An architectural style for designing web services ☑️
    • Helps answer the question on how to organize routes and how to map functionality to URIs and Methods:
      • Paths represent "nouns" or resources
      • HTTP “verbs” map to data operations
  • A algorithm for parsing the text of an HTTP request
    • Express parsing middleware (Body Parser)

Select all HTTP verbs:

  • GET ☑️
  • SET
  • POST ☑️
  • PUT ☑️
  • UPDATE
  • REMOVE
  • DELETE ☑️

What is the express body parser and why do we use it?

  • It's a piece of middleware in which it extracts data from a form and makes it available to req.body. This is needed because data on the internet is not necessarily sent in wholesale but in packets.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment