Express Flashcards

1
Q

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

What Express application method binds the server to a network PORT?

A

app.listen

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

How do you register a middleware with an Express application?

A

app.use()

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

Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?

A

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.

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

What is the Content-Type header of HTTP requests and responses used for?

A

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

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

What does express.static() return?

A

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)

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

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

A

returns the path of the folder where the current JavaScript file resides

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

What does the join() method of Node’s path module do?

A

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.

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