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
When was Node.js created?
2009
26
What is the process object in a Node.js program?
It is a global object that provides information about, and control over, the current process
27
How do you access the process object in a Node.js program?
- 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
What is the data type of process.argv in Node.js?
An array of strings
29
What is a JavaScript module?
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
What values are passed into a Node.js module's local scope?
exports, require, module, __filename, __dirname
31
Give two examples of truly global variables in a Node.js program.
Console and process
32
What is the purpose of module.exports in a Node.js module?
To be able to use data in one module in another module
33
How do you import functionality into a Node.js module from another Node.js module?
You use require to import the functionality
34
What is a directory?
A special kind of file that lists other files
35
What is a relative file path?
The path to go from one directory to another file
36
What is an absolute file path?
The path to a file form the root directory
37
What module does Node.js include for manipulating the file system?
fs module
38
What method is available in the Node.js fs module for writing data to a file?
The writeFile method
39
Are file operations using the fs module synchronous or asynchronous?
Yes | - Base versions are asynchronous but Sync versions are synchronous
40
What is NPM?
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
What is a package?
A package is a directory with at least one file and a package.json file
42
How can you create a package.json with npm?
With the npm init command
43
What is a dependency and how do you add one to a package?
- 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
What happens when you add a dependency to a package with npm?
- It creates a module folder with the required package | - It updates the package.json file to require the dependencies
45
How do you add express to your package dependencies?
npm install express or just npm i express
46
What Express application method starts the server and binds it to a network PORT?
The listen() method
47
How do you mount a middleware to an Express application?
By using the use method or the HTTP request method as a method of the app object
48
Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?
Request object and response object
49
What is the appropriate Content-Type header for HTTP messages that contain JSON in their bodies?
application/json; charset=utf-8
50
What is the significance of an HTTP request's method?
- 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
What does the express.json() middleware do and when would you need it?
- 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