Express.js Flashcards

1
Q

What is a client?

A

A client is a requester of a service

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

What is a server?

A

A server provides a function or service to one or many clients

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

Which HTTP method does a browser issue to a web server when you visit a URL?

A

GET method

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

What is on the first line of an HTTPrequestmessage?

A

Method, Request Target, HTTP Version

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

What is on the first line of an HTTPresponsemessage?

A

HTTP Version, Status Code, Status Text

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

What are HTTP headers?

A

HTTP Headers let the client and server pass additional information with an HTTP request or response.

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

Is a body required for a valid HTTP message?

A

No

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

How do you addexpressto your package dependencies?

A

npm install express

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

What Express application method starts the server and binds it to a networkPORT?

A

listen() method

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

How do you mount a middleware with an Express application?

A

use() method

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

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

A
  • Req object

- Res object

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

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

A

It parses incoming requests with JSON payloads and attaches to body of req object

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

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

A

Runs the code block

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

What is the appropriateContent-Typeheader for HTTP messages that contain JSON in their bodies?

A

Content-Type: application/json; charset=utf-8

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

What doesexpress.static()return?

A

A middleware function

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

What is the local__dirnamevariable in a Node.js module?

A
  • The directory name of the current module
- console.log(\_\_dirname);
	// Prints: /Users/mjr
17
Q

What does thejoin()method of Node’spathmodule do?

A

Thepath.join()method joins all givenpathsegments into a single path