Express Flashcards
How do you add express to your package dependencies?
npm install express
What Express application method binds the server to a network PORT?
app.listen
How do you register a middleware with an Express application?
app.use()
Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?
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.
What is the Content-Type header of HTTP requests and responses used for?
The Content-Type entity header is used to indicate the media type of the resource. In responses, a Content-Type header tells the client what the content type of the returned content actually is
How the recipient should handle the body content
What does express.static() return?
express.static is a piece of middleware that comes built into Express, it’s purpose is to try to find and return the static file requested. The parameter we pass to the express.static function is the name of the directory we want Express to serve files from (such as public)
What is the local __dirname variable in a Node.js module?
returns the path of the folder where the current JavaScript file resides
What does the join() method of Node’s path module do?
The path.join() method joins the specified path segments into one path.
You can specify as many path segments as you like.
The specified path segments must be strings, separated by comma.