reading-notes

These are my reading notes for Code Fellows


Project maintained by taegorov Hosted on GitHub Pages — Theme by mattgraham

Home

Express REST API

Name 3 real world use cases where you’d want to change the request with custom middleware

  1. If you want block a page of your website unless someone is logged in
  2. Cyber security
  3. Error handling

True or false: The route handler is middleware?

False

In what ways can a middleware function end the process and send data to the browser?

End the process with next(), send data with response.status(error code here).send

At what point in the request lifecycle can you “inject” middleware?

The middleware is injected right after the first request to the server, assuming that request uses next() along with request and response.

What can cause express to error with “Request headers sent twice, cannot start a second response”

When duplicate responses are sent to the user or the server.

Document the following Vocabulary Terms:

Middleware functions are functions that have access to the request object (req), the response object (res), and the next middleware function in the application’s request-response cycle. The next middleware function is commonly denoted by a variable named next. (source)

the req object is one half of the request and response cycle to examine calls from the client side, make HTTP requests, and handle incoming data whether in a string or JSON object. (source)

the res object is one half of the request and response cycle to send data from the server to the client-side through HTTP requests. (source)

app.use(), app.get(), and the like. Sends requests to the server.

The function is executed every time the app receives a request. (source)

Router-level middleware works in the same way as application-level middleware, except it is bound to an instance of express.Router(). (source)

next() – ensures that

“Test-driven development” refers to a style of programming in which three activities are tightly interwoven: coding, testing (in the form of writing unit tests) and design (in the form of refactoring).(source)

[Behavioral testing] means writing automated tests in a language that is meaningful to the business people. So where technical language is OK in TDD, you would want to avoid it in BDD. (source)

“Outside-in”