NPM/Express/PostGres Flashcards
What is NPM?
Its a package manager that allows us to install dependencies into our project, essentially modules.
A giant website/massive collection of modules where user can upload solution to the problem they solved so other people can use it also. is the world’s largest software registry, where user can share and borrow packages
What is a package?
Essentially, its a module that we can get access to.
A package is:
a) a folder containing a program described by a package.json file
b) a gzipped tarball containing (a)
c) a url that resolves to (b)
d) a <name>@<version> that is published on the registry (see registry) with (c)
e) a <name>@<tag> (see npm dist-tag) that points to (d)
f) a <name> that has a "latest" tag satisfying (e)
g) a <git> that resolves to (a)</git></name></tag></name></version></name>
How can you create a package.json with npm?
with the command npm init –yes/npm init
What is a dependency and how to you add one to a package?
Its what required for your application to work
npm install <package-name> [--save-prod]/npm i <package></package></package-name>
What happens when you add a dependency to a package with npm?
the Dependencies will get stored in the package. json file. and we get node module folder. (all the info needed for your application to run)
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?
app.listen()
How do you mount a middleware with an Express application?
with use method
Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?
respond(res) and req(request) object
What is middleware?
Its just a function that get called, it does something to the request, and then the request continues. Its a function that add some functionality somewhere in the process. A common thing middleware might do is run some authentication software, print something to the console…software that acts as a bridge between an operating system or database and applications, especially on a network.
What is the appropriate Content-Type header for HTTP messages that contain JSON in their bodies?
app/json
What is the significance of an HTTP request’s method?
HTTP defines a set of request methods to indicate an action to be performed for a given resource. It also, allows us to set up individual routes depending on what method was used.
What is params?
Params is always going to contain whatever data is in the url of the request. app.delete(‘/api/grades/:id’)
const id = Number(req.params.id)
What does the express.json() middleware do and when would you need it?
When we call the middleware, it returns to us a body parser and if we use that with the use method on the express server that we created, then it would take any json that is sent in the body of the request and convert it so then we can use inside of our end point. We need anytime that we are sending json on the body of request. It allows us to parse the body of json so then we can use it inside of our code.
What is PostgreSQL and what are some alternative relational databases?
Its a free way to store your data for server
MySQL, SQL Server by Microsoft, and Oracle by Oracle Corporation.