Express Flashcards
What is a client?
program or device that sends requests
what is a server?
program or device that receives requests from clients and sends back a response
HTTP method when. you visit a url
GET
first line of an HTTP request message?
The method protocol, target and version
first line of an HTTP response message?
protocol, version status code and status message
HTTP headers
metadata
is the body required for a valid HTTP message?
nope
what is NPM
NPM is the package manager for the Node JavaScript platform. It puts modules in place so that node can find them, and manages dependency conflicts intelligently.
npm consists of three distinct components:
• the website
• the Command Line Interface (CLI)
• the registry
What is a package in npm
files of. code and it includes a package.json
create a package.json with npm
npm init –yes
What is a dependency and how to you add one to a package?
something that your code depends on. You add by npm install
what happens when you install a dependency with npm?
adds another module in your directory and is assigned to the json file as a dependency
What express application method starts the server and binds it to a network PORT?
app.listen(path, [callback])
how to you mount a middleware with an Express application?
the use method
What objects does an Express application pass to your middleware to manage the request/response lifecycle of a server?
request and response objects
What is the appropriate content type header for HTTP messages that contain JSON in their bodies?
application/json
What does the express.json() middleware do and when do you need it?
if an incoming requisition message is application/json and the body is a string, it will parse the string
its needed for incoming request messages to parse bodies that are JSON
what is the significance of an HTTP request message?
you can change and update data in your code and for communication purposes. it expresses what the client wants to do and the server responds accordingly
What does express.static() return?
a function
what is the local __dirname variable in a Node.js module?
the absolute path to the current directory.
what does the join() method of Nodes path module do?
it joins strings to create a file path, putting slashes between them.