Node Flashcards

1
Q

How do you mount a middleware with an Express application?

A

Call the method of the app object

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

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

A

Request and response

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

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
4
Q

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

A

express.json() middleware is used to handle JSON request lines

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

What is Webpack?

A

A tool that lets you bundle your JavaScript applications and can be extended to support many different assets such as images, fonts and stylesheets

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

How do you add a devDependency to a package?

A

npm install –save-dev

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

What is an NPM script?

A

Convenient way to bundle common shell commands for projects

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

How do you execute Webpack with npm run?

A

Add a script to run webpack in the scripts objects of the package.json
“build”: “webpack”

npm run build

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

What does express.static( ) return?

A

express.static returns a middleware function that possibly sends the static files from its given parameter

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

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

A

the 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

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

A

joins all given path segments together and returns the result

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