Express.js Flashcards

1
Q

[Express Intro]

How do you add ‘express’ to your package dependencies?

A

npm install express

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

[Express Intro]

What express application method starts the server and binds it to a network PORT?

A

the listen method

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

[Express Hello World]

How do you mount a middleware with an Express application?

A

use methods from the app object. These are the responses for requests made to the server such as app.use, app.get, app.post

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

[Express Hello World]
Which objects does an Express application pass to your middleware to manage the requests/response lifecycle of the server?

A

request (req) and response (res)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

[Express get JSON]

What is the appropriate Content-Type header for HTTP messages that contain JSON in their bodies?

A

application/json

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

[Express Post JSON]

What does the express.json() middleware do and when would you need it?

A

it will parse incoming json body

when the

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

[Express Delete]

What is the significance of an HTTP request’s method?

A

for getting values from their position in the URL and using them in the app

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

[Express Hello World]

What is middleware?

A

Sort of like event listeners for requests

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

[Express Static]

What does ‘express.static()’ return?

A

the ‘serveStatic’ middleware function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

[Express Static]

What is the local ‘__dirname’ variable in a Node.js module?

A

an absolute path to the directory name of the current module

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
[Express Static]
What does the join() method of Node's path module do?
A

joins path segments together into one path as a string

How well did you know this?
1
Not at all
2
3
4
5
Perfectly