HTTPS/Node/Express Flashcards

1
Q

What is a client?

A

Service REQUESTERS are clients (users?) - something that is CONSUMING resources

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

What is a server?

A

Service PROVIDERS are servers

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

The GET method

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

What three things are on the start-line of an HTTP request message?

A

HTTP method (verb like GET, PUT, POST. . . or noun like HEAD or OPTION)
-How is the request being made?
Request Target - usually a URL or absolute path
-Where is the request going?
The HTTP version (defines structure of remaining message)

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

What three things are on the start-line of an HTTP response message?

A

The protocol version (usually HTTP/1.1)
The status code - indicates success or failure of request
The status text - brief, informational, textual description of the status code

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

What are HTTP headers?

A

Headers are where the client and server can pass additional information with an HTTP request or response.

- General Headers - apply to the message as a whole
- Request Headers - modify the request by specifying it further, giving context, or restricting it
- Representation Headers - describe the original format of the message data
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Where would you go if you wanted to learn more about a specific HTTP Header?

A

MDN

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

Is a body required for a valid HTTP request or response message?

A

A body is not required

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

What is a CLI?

A

Command Line Interface

- An interface that receives commands from the user via text

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

What is a GUI?

A

Graphical User Interface

- An interface that receives commands from users via graphical icons and audio indicators

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

Give a use case for the following command:

man

A

Manual lists information on a command

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

Give a use case for the following command:

cat

A

Concatenates files

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

Give a use case for the following command:

ls

A

Lists directory contents

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

Give a use case for the following command:

pwd

A

Prints the name of the current/working directory

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

Give a use case for the following command:

echo

A

Displays a line of text . . . “echoes” the text input

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

Give a use case for the following command:

touch

A

Change files timestamps

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

Give a use case for the following command:

mkdir

A

Makes directories

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

Give a use case for the following command:

mv

A

Moves or renames files

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

Give a use case for the following command:

rm

A

Removes files

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

Give a use case for the following command:

cp

A

Copies files and/or directories

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

What are the three virtues of a great programmer?

A

1) Laziness:
The quality that makes you go to great effort to reduce overall energy expenditure. It makes you write labor-saving programs that other people will find useful and document what you wrote so you don’t have to answer so many questions about it.
2) Impatience:
The anger you feel when the computer is being lazy. This makes you write programs that don’t just react to your needs, but actually anticipate them. Or at least pretend to.
3) Hubris:
The quality that makes you write (and maintain) programs that other people won’t want to say bad things about.

22
Q

What is Node.js?

A

Node.js is a program that allows JavaScript to be run outside of a browser

23
Q

What can Node.js be used for?

A

It can be used to build backend Web applications, command-line programs, and automation

24
Q

What is a REPL?

A

Read-eval-print loop
- a simple interactive computer programming environment that takes single user inputs, executes them, and returns the result to the use

25
Q

When was Node.js created?

A

2009

26
Q

What is the process object in a Node.js program?

A

It is a global object that provides information about, and control over, the current process

27
Q

How do you access the process object in a Node.js program?

A
  • You can access it using the require(‘process’); function and assigning it to a variable or logging it to the console
  • Because it is global you can just access it with the process name
28
Q

What is the data type of process.argv in Node.js?

A

An array of strings

29
Q

What is a JavaScript module?

A

A JavaScript module is a section of a program, a small section of a larger database. It is a JavaScript file in this context.

30
Q

What values are passed into a Node.js module’s local scope?

A

exports, require, module, __filename, __dirname

31
Q

Give two examples of truly global variables in a Node.js program.

A

Console and process

32
Q

What is the purpose of module.exports in a Node.js module?

A

To be able to use data in one module in another module

33
Q

How do you import functionality into a Node.js module from another Node.js module?

A

You use require to import the functionality

34
Q

What is a directory?

A

A special kind of file that lists other files

35
Q

What is a relative file path?

A

The path to go from one directory to another file

36
Q

What is an absolute file path?

A

The path to a file form the root directory

37
Q

What module does Node.js include for manipulating the file system?

A

fs module

38
Q

What method is available in the Node.js fs module for writing data to a file?

A

The writeFile method

39
Q

Are file operations using the fs module synchronous or asynchronous?

A

Yes

- Base versions are asynchronous but Sync versions are synchronous

40
Q

What is NPM?

A

NPM is a software registry where open source developers can borrow and share packages of code. There are three primary components:

  • The Website
  • The Registry
  • The CLI
41
Q

What is a package?

A

A package is a directory with at least one file and a package.json file

42
Q

How can you create a package.json with npm?

A

With the npm init command

43
Q

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

A
  • A dependency is third-party code that is required at runtime (generally a package)
  • You can add a dependency with the npm install command
44
Q

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

A
  • It creates a module folder with the required package

- It updates the package.json file to require the dependencies

45
Q

How do you add express to your package dependencies?

A

npm install express or just npm i express

46
Q

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

A

The listen() method

47
Q

How do you mount a middleware to an Express application?

A

By using the use method or the HTTP request method as a method of the app object

48
Q

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

A

Request object and response object

49
Q

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

A

application/json; charset=utf-8

50
Q

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

A
  • It tells the server what type of request a client is making
  • It allows us as the programmer to determine what response to send the client
51
Q

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

A
  • It parses the json body of incoming requests

- We would need to mount it to our server if we are expecting clients to send json to the server