Express.js Flashcards

1
Q

What is Express useful for?

A

Implementing HTTP endpoints. Helps manage routes.

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

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

A

Runs on top of node and manages the HTTP requests between front end and back end.

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

How do you add express to your package dependencies?

A

npm install command. “npm install express”

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

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

A

app.listen()

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

What is Express middleware?

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

What is Express middleware useful for?

A

Carry out functions inbetween express and the http request.

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

How do you mount a middleware with an Express application?

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

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

A

The request object, the response object, and the next middleware function.

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

What is Express middleware useful for?

A

Carry out functions in-between express and the http request.

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

What is an API endpoint?

A

The path or URL for backend API plus its prefix, e.g. /api/grades. It makes it easier to determine which endpoints are intended for which types of request. With this information, Express code can more easily optimize each style of API for its intended use.

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

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

A

application/json; charset-utf-8

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

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

A

An HTTP request’s method indicates what action will be performed.

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

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

A

Returns middleware that only parses JSON and only looks at requests where the Content-Type header matches the type option. You need it to parse JSON request bodies.

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

What does app.listen() do?

A

It puts something on the event queue that listens for network requests/traffic. When there is a request, it runs through the middleware and then puts the listener back on the event queue.

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

What is the purpose of the Express Static middleware?

A

To serve static files.

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

What does express.static() return?

A

A middleware object that returns a response object, or if not found, it will call next().

17
Q

What are several examples of static files?

A

Images, CSS files, JavaScript files, text files, sound files, video files, etc.

18
Q

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

A

By using express.static().