Reading-Notes

Readings

Review: ES6 Classes

Classes are a template for creating __.

objects

Can a class declaration be hoisted?

not normally, unless ‘let’ or ‘const’ are involved (?)

How would you describe a constructor and contextual “this” to a non-technical friend?

A constructor is a Bob the builder, he makes objects by contructing them out of what is defined as needed, and like Bob, they are one of a kind, if there were two the matix would crase (ie. syntax error).

As for the contexutual this, excuse my literal nature but if you were to draw a chaulk circle around a group of things, you could point at each “thing” and say within the “context” that is the “this”. Call the chaulk circle the object, within the object the things are referred to as the contextual this.

Using Express Routing

Within Express, what does routing refer to?

Routing refers to how an application’s endpoints (URIs) respond to client requests… You define routing using methods of the Express app object that correspond to HTTP methods; https://expressjs.com/en/guide/routing.html

What is the difference between a route path and a route method?

A route method is derived from one of the HTTP methods, and is attached to an instance of the express class.

Route paths, in combination with a request method, define the endpoints at which requests can be made. Route paths can be strings, string patterns, or regular expressions.

When is it appropriate to add next as a parameter to a route handler and what must you do if next has been passed to your middleware as a parameter?

When you are wanting to provide multiple callback functions that behave like middleware to handle a request, they might have to utilize the ‘next’ in order to side step the remaining route call backs. You can use next to tell the route how to play, then pass the baton onto the next route if there is no reason to continue on the current one.

Express Routing

What is an Express Router?

Provides routing API’s like .use, .get, ect.

By what means do we initialize express.Router() in an express server?

What do we use route middleware for?

Route middleware in Express is a way to do something before a request is processed. This could be things like checking if a user is authenticated, logging data for analytics, or anything else we’d like to do before we actually spit out information to our user. https://www.digitalocean.com/community/tutorials/learn-to-use-the-new-router-in-expressjs-4

Reflection

What are your learning goals after reading and reviewing the class README?

I’m excited to see what all we can do with the express router after reading about all the good it can do for a server.