Skip to content

Instantly share code, notes, and snippets.

@nrl240
Last active March 9, 2021 15:18
Show Gist options
  • Save nrl240/208cd52e9edc7278ccec6d355403384c to your computer and use it in GitHub Desktop.
Save nrl240/208cd52e9edc7278ccec6d355403384c to your computer and use it in GitHub Desktop.
Exit Ticket: Day 6 - Express and Handling Asynchronous Code

Exit Ticket: Day 6 - Express and Handling Asynchronous Code

You should be able to:

  • Describe the role of a client, a server, and HTTP
  • Describe Express middleware, requests, and responses
  • Handle URL params in an Express route
  • Know when and why you would use app.use and next in your Express app
  • Explain the purpose of using async/await & Promises

In your own words, what is a server?

  • A HTTP server listens for HTTP requests and sends HTTP responses.

Reference: MDN: What is a web server?

What is the purpose of the package.json file in a Node project?

  • Store a list of dependencies for the project
  • Give the project a name
  • Store metadata about the project
  • All of the above ☑️
  • None of the above

Reference:

What is Express?

  • Node web framework for handling requests ☑️
    • Provides mechanisms to:
      • Write handlers for requests with different HTTP verbs at different URL paths (routes)
      • Set common web application settings like the port to use for connecting
      • Add additional request processing “middleware” at any point within the request handling pipeline
  • JavaScript runtime environment
  • JavaScript library for building user interfaces
  • An ORM

Reference:

Which of the following statements are true about Express Middleware?

  • An example of it could be app.use ☑️
  • It happens between the request and response ☑️
  • Only one middleware function can be called per request-response cycle
  • An example of it could be app.get ☑️
  • It sometimes runs after the response is sent

Reference:

  • Express: Using middleware
    • In reference to app.get, in this doc, it says, "Express is a routing and middleware web framework that has minimal functionality of its own: An Express application is essentially a series of middleware function calls." Technically, since Express is built on top of and leverages Node, Express sits in between the request and response.
  • Express: Writing middleware for use in Express apps
  • Express: app.use()
  • A function that receives the request and response objects of an HTTP request/response cycle (i.e. (req, res, next) => {...}).

What is a Promise?

  • A function that runs asynchronous code
  • A keyword that marks a function as having asynchronous code
  • A callback function that executes after an asynchronous operation finishes
  • An object that represents the eventual completion of an asynchronous operation and its resulting value ☑️

Reference:

Which of the following statements is true about async/await?

  • You can use await outside of an async function
  • async functions are not Promises when the return value is not a Promise itself
  • Inside of an async function, the code behaves synchronously ☑️
  • async functions are synchronous

Reference:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment