Node/express Flashcards

1
Q

Routing refers to…

A

… determining how an application responds to a client request to a particular endpoint.

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

What’s an endpoint?

A

A URI (or path) and a specific HTTP request method (GET, POST, and so on).

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

What’s a route? (Express)

A

A combination of path and http verb.

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

How is a route definition structured in express?

A

app.METHOD(PATH, HANDLER)
METHOD = http verb in lowercase
PATH = uri/ path on server
HANDLER = function to execute when route (path + method) is matched

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

What four verbs are possible in routes in express?

A

Get, post, put, delete

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

What are the two parameters of the handler function in an express route?

A

Request and response:
(req, res) => {
res.send(“response “)
}

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

What is the method for using middleware in express?

A

app.use( )

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

What’s the default path for app.use?

A

“/“ (meaning the root)

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

How to serve static files in express?

A

app.use(express.static(‘public ’)
“Public” represents the root directory of where your static files are.

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