Express Flashcards
How do you add express to your package dependencies?
you install express, npm install
What Express application method starts the server and binds it to a network PORT?
.listen(3000, callback)
network interface
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 do you mount a middleware with an Express application?
using the use method. like add event listeners for requests.
middlewares must send a response or have next().
Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?
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
What is the appropriate Content-Type header for HTTP messages that contain JSON in their bodies?
application/json
What is the significance of an HTTP request’s method?
indicate the desired action to be performed for a given resource
What does express.static() return?
it returns a middleware function
What is the local __dirname variable in a Node.js module?
__dirname is an environment variable that tells you the absolute path of the directory containing the currently executing file
What does the join() method of Node’s path module do?
join() method joins the specified path segments into one path.