Express Flashcards
What is NPM?
a package manager where programmers can share their codes
What is a package?
a list of modules (package json file)
How can you create a package.json with npm?
npm init – yes
What is a dependency and how to you add one to a package?
dependency is package that is added to
npm install ____
What happens when you add a dependency to a package with npm?
node-module is added to directory and dded to dependencies
How do you add express to your package dependencies?
npm install express
What Express application method starts the server and binds it to a network PORT?
listen()
How do you mount a middleware with an Express application?
use()
middleware is processing of requesting and responding
Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?
requires()
What is the appropriate Content-Type header for HTTP messages that contain JSON in their bodies?
application/json
send() ->JSON.stringify variable and array only
json() ->JSON.stringify variable, array, boolean, null
What does the express.json() middleware do and when would you need it?
automatically parse the json data when the client requests
app.use(express.json())
What is the significance of an HTTP request’s method?
path
ex: app.delete(‘path’ , (req, res) => {
})
path = ‘/api/grades/:id’ -> req.params.id
typing after path in command line -> req.body