Express Flashcards
How do you add express to your package dependencies?
You add express to your package dependencies by npm install express
What Express application method starts the server and binds it to a network PORT?
listen method
How do you mount a middleware with an Express application?
use() and pass middleware function as argument
Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?
req, res
What is the appropriate Content-Type header for HTTP messages that contain JSON in their bodies?
application/JSON
What does the express.json() middleware do and when would you need it?
It parses incoming requests - we would need it when we receive json in the body from the client and need it to parse it
What is the significance of an HTTP request’s method?
determines what action should be done with the given resource but programmer can make it do whatever if empty code block, then httpie freezes fro 30s
What does express.static() return?
returns middleware function/ static file requested
What is the local __dirname variable in a Node.js module?
it is a absolute path - tells you the absolute path of the directory containing the currently executing file
What does the join() method of Node’s path module do?
Joins all given paths together