NPM - Express Flashcards
What is NPM?
a website,
CLI,
a registry,
What is a package?
reusable code
a directory with files in it
contains package.json
How can you create a package.json with npm?
npm init –yes
What is a dependency and how do you add one to a package?
It’s a package that your app/website needs in order to run. You add one with the install command
What happens when you add a dependency to a package with npm?
The dependency property in package.json is updated and it allows you to use the dependency by downloading it from the npm resgistry and puts it into node modules
How do you add express to your package dependencies?
you use the npm install command
npm install express
What Express application method starts the server and binds it to a network PORT?
the listen method()
it takes the optional parameters ([port[, host[, backlog,]]] and [callback]
How do you mount a middleware with an Express application?
with the use() method
it will be mounted at the path specified
Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?
it passes the req (request) object and the res (response) object to the middleware
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 would you need it?
parses incoming JSON request bodies
and you will need it when you are requesting incoming JSON request bodies
What is the significance of an HTTP request’s method?
it’s semantic
What is Webpack?
it allows you to bundle all the modules of your dev environment in one place
no bottlenecking with script tags
How do you add devDependency to a package?
npm install –save-dev webpack
npm install –save-dev webpack-cli
How do you execute Webpack with npm run?
npm run build