Node part 2 Flashcards

1
Q

What is a client?

A

the one that makes service requests

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

What is a server?

A

the one that provides a resource or service

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 request

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 HTTP request message?

A

Their start-line contain three elements:
HTTP Method (get, post, put),
Request Target: (URL),
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 HTTP response message?

A
Status line:{
Protocol 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

List of key value pairs in the header of the 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

What is NPM?

A

a package manager for JavaScript: website, command line interface, and registry:
to shared data and packages, etc.

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

What is a package?

A
  • a folder containing a package.json program that lists the your projects dependencies
  • specifies versions of packages
  • makes your build reproducible, to share with other devs

(directory with one or more files, and a package.json file)

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

How can you create a package.json with npm?

A

use the npm init command in the root directory of package

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

What is a dependency and how do you add one to a package?

A

packages that your project depends on,

you can list them as “dependencies” in package.json

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

What happens when you add a dependency to a package with npm?

A

the project will install all listed dependencies with the install command

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

How do you add express to your package dependencies?

A

it will be added when you use npm install express

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

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

A

listen()

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

How do you mount a middleware with an Express application?

A

app.use() / app.METHOD() ?

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

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

A

req, and res

17
Q

What is the purpose of the Content-Type header in HTTP request and response messages?

A

.

18
Q

What does express.static() return?

A

serveStatic function

19
Q

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

A

absolute path to the current module

20
Q

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

A

combines multiple strings into a directory path format

21
Q

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

A

application/json

22
Q

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

A

parses incoming json requests, and creates an empty body(object) - req.body

23
Q

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

A

just syntax, to give user control