Express.js Flashcards
[Express Intro]
How do you add ‘express’ to your package dependencies?
npm install express
[Express Intro]
What express application method starts the server and binds it to a network PORT?
the listen method
[Express Hello World]
How do you mount a middleware with an Express application?
use methods from the app object. These are the responses for requests made to the server such as app.use, app.get, app.post
[Express Hello World]
Which objects does an Express application pass to your middleware to manage the requests/response lifecycle of the server?
request (req) and response (res)
[Express get JSON]
What is the appropriate Content-Type header for HTTP messages that contain JSON in their bodies?
application/json
[Express Post JSON]
What does the express.json() middleware do and when would you need it?
it will parse incoming json body
when the
[Express Delete]
What is the significance of an HTTP request’s method?
for getting values from their position in the URL and using them in the app
[Express Hello World]
What is middleware?
Sort of like event listeners for requests
[Express Static]
What does ‘express.static()’ return?
the ‘serveStatic’ middleware function
[Express Static]
What is the local ‘__dirname’ variable in a Node.js module?
an absolute path to the directory name of the current module
[Express Static] What does the join() method of Node's path module do?
joins path segments together into one path as a string