HTTP, NPM, NODE, Express Flashcards

1
Q

What is a client?

A

A service requestor.

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

What is a server?

A

A service provider.

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

a get request

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

The method, verbs i.e. GET PUT, POST or a noun HEAD, OPTIONS, the target (URL), HTTP version

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

Version ie. (HTTP/1.1),
status code (404),
status text i.e. 404 Not found (for human reading)

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

What are HTTP headers?

A

A string followed by colons and a value.
A key value pair.

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

No. Their could just be a confirmation in the start line.

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

What is AJAX?

A

Asynchronus processing request, to load data with having a user reload a page.

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

What does the AJAX acronym stand for?

A

Asynchronous JavaScript And XML

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

Which object is built into the browser for making HTTP requests in JavaScript?

A

XMLHttpRequest object.

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

What event is fired by XMLHttpRequest objects when they are finished loading the data from the server?

A

load event.

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

Bonus Question: An XMLHttpRequest object has an addEventListener() method just like DOM elements. How is it possible that they both share this functionality?

A

Prototype inheritance from the window.

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

What is NPM?

A

Node-package manager.

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

What is a package?

A

A directory with one or more files, of a chunk of reusable code.

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

How can you create a package.json with npm?

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

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

A

A package that your package requires you to use. Version control, majorversion(breaking changes).minorversion(adds functionality backwards compat).bugfixversion(fixes something, should always update this)

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

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

A

It gets put into your package.json, and downloads the package and all dependencies in your node-modules.

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

What are some other popular package managers?

A

Yarn and PNPM.

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

DEV dependencies.

A

Packages for when your in development, so they can easily removed at launch.

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

Scripts in npm?

A

Scripts allow you to create shortcut keywords to run different packages.

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

What is Express useful for?

A

Handling server requests.

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

How does Express fit into a full-stack web application?

A

It helps handle your server requests, to get data from databases and send it to the client.

24
Q

How do you add express to your package dependencies?

A

npm i express

25
Q

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

A

.listen , we use port 8080 / With httppie you can just do < http :8080 > It assumes GET and localhost

26
Q

What is Express middleware?

A

Function calls that respond to requests made to express.

27
Q

What is Express middleware useful for?

A

Modify your data, return an html page, send a file to be downloaded? Lots of things?

28
Q

How do you mount a middleware with an Express application?

A

You pass a directory as an argument and when the routing goes through this code is executed with the use method.

29
Q

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

A

The request and response objects.

30
Q

Whats an api endpoint?

A

A specific URL.

31
Q

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

A

application/json.

32
Q

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

A

A generalization of what a server should do.

33
Q

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

A

Parses incoming JSON.

34
Q

What is SQL and how is it different from languages like JavaScript?

A

It’ s declarative, it does what you ask.

35
Q

How do you retrieve specific columns from a database table?

A

select followed by the column and then a from what table

36
Q

How do you filter rows based on some specific criteria?

A

use the where keyword followed by column and your comparator statement.

37
Q

What are the benefits of formatting your SQL?

A

READABILITY!

38
Q

What are four comparison operators that can be used in a where clause?

A

=, !=, <, >

39
Q

How do you limit the number of rows returned in a result set?

A

the limit keyword followed by a number, must be last statement.

40
Q

How do you retrieve all columns from a database table?

A

select *
from “tablename”

41
Q

How do you control the sort order of a result set?

A

order by keyword ,defaults ascending, specify <desc> after the column name.</desc>

42
Q

How do you add a row to a SQL table?

A

insert into “tablename” (“columnname”, “columnname”)

43
Q

What is a tuple?

A

A list of values inside parentheses.

44
Q

How do you add multiple rows to a SQL table at once?

A

add commas between tuples.

45
Q

How do you get back the row being inserted into a table without a separate select statement?

A

returning * will return all sent. Is good to see autogenerated IDs

46
Q

How do you update rows in a database table?

A

update <tablename>, set <valuename> = <value>, usually followed by a filter statement
where <attribute> = <value></value></attribute></value></valuename></tablename>

47
Q

Why is it important to include a where clause in your update statements?

A

The where clause specifies which rows you should update.

48
Q

How do you delete rows from a database table?

A

DELETE
FROM <tableName>
WHERE <attributeName> = <value>
returning *;</value></attributeName></tableName>

49
Q

How do you accidentally delete all rows from a table?

A

Forgetting a where statement.

50
Q

What is a foreign key?

A

A reference to the primary key of another table.

51
Q

How do you join two SQL tables?

A

JOIN <tableName> using (<columnName>)</columnName></tableName>

52
Q

How do you temporarily rename columns or tables in a SQL statement?

A
53
Q

What is the purpose of the Express Static middleware?

A

to serve basic files to the client.

54
Q

What does express.static() return?

A

Returns a response object or calls next.

55
Q

What are several examples of static files?

A

CSS, Images, Index.html(when using react), basic javascript. Any files that don’t change and aren’t dynamic like react?

56
Q

What is a good way to serve application images using Express?

A

Using relative links to a static image folder. Serving them statically.