Express Flashcards

1
Q

What is Express?

A

Express is a routing and middleware web framework for Node.js that has minimal functionality of its own: An Express application is essentially a series of middleware function calls.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
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
3
Q

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

A

app.listen([port[, host[, backlog]]][, callback])

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

How do you register a middleware with an Express application?

A

app.use([path,] callback [, callback…])

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

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

A

request object, response object, and the next middleware

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
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.

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

What does express.static() return?

A

Express.static() serves static files contained in the root directory

Syntax: express.static(root, [options])

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

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

A

A string of the absolute path of the current module directory

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

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

A

The path.join() method joins all given path segments together using the platform-specific separator as a delimiter, then normalizes the resulting path.

Syntax: path.join([…paths])

Example: path.join('/foo', 'bar', 'baz/asdf', 'quux', '..');
// Returns: '/foo/bar/baz/asdf'
How well did you know this?
1
Not at all
2
3
4
5
Perfectly