Express Flashcards

1
Q

How do you add express to your package dependencies?

A

you install express, npm install

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

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

A

.listen(3000, callback)

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

network interface

A

is a piece of hardware on a computer that allows net work connectivintiy(internet)
examples: wifi card/adapter, lan card
lan: local area network
// your phone and laptop have wifi cards.
// your laptop may have lan/
//your desktop has lan maybe both
// every network interface provides 2^16 ports. port is where network connectivity can flow.
// the default http port is 80. *
// default https port is 443. *
// anything below 1024 requires admin privileges to use. *
// each netowrk interface is given its own ip address on your network.
// what is the diffrence btween a library and a framework. library is code that someone else wrote or a separate part of your code base. a library should be reuseable(flexible).
// a framework is a specific kind of library.
//a frame work id different from a library when it has ‘inversion of control’.

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

How do you mount a middleware with an Express application?

A

using the use method. like add event listeners for requests.

middlewares must send a response or have next().

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

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

A

the req and res object

req: a data model of the http request from the client
res: a data model of the http response message to the client

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

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

A

application/json

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

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

A

indicate the desired action to be performed for a given resource

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

What does express.static() return?

A

it returns a middleware function

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

What is the local __dirname variable in a Node.js module?

A

__dirname is an environment variable that tells you the absolute path of the directory containing the currently executing file

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

What does the join() method of Node’s path module do?

A

join() method joins the specified path segments into one path.

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