Senior Side Week 2 & 3 Flashcards
(102 cards)
What is a client?
A client is a computer program or device that requests services or resources from a server.
The client sends a request to the server, which processes the request and sends a response back to the client.
Example: A broswer
What is a server?
A server is a computer program or device that provides services or resources to clients.
The server is responsible for processing requests from clients and returning the requested information or service.
Examples: web servers, mail servers, file servers, database servers, and game servers.
Which HTTP method does a browser issue to a web server when you visit a URL?
GET
What is on the first line of an HTTP request message?
HTTP Method, Request Target, HTTP Version
What is on the first line of an HTTP response message?
Protocol Version, Status Code, Status Text
What are HTTP headers?
HTTP headers let the client and the server pass additional information with an HTTP request or response. An HTTP header consists of its case-insensitive name followed by a colon (:), then by its value
Is a body required for a valid HTTP message?
Depends on the specific requirements of the HTTP method being used and the specific circumstances of the request or response.
For some HTTP methods, such as GET and HEAD, a message body is not required, and any included message body would be ignored by the server. For other methods such as POST, PUT, and DELETE, a message body may be required to send or modify data associated with the request.
What is NPM?
NPM is the world’s largest software registry. Open source developers from every continent use npm to share and borrow packages.
The 3 components in the npm is:
the website
the command line interface (CLI)
the registry
What is a package?
A package is a file or directory that is described by a ‘package.json’. A package must contain a ‘package.json’ file in order to be published to the npm registry.
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?
In package.json file, there is an object called dependencies and it consists of all the packages that are used in the project with its version number. So, whenever you install any library that is required in your project that library you can find it in the dependencies object.
Basically means that the package depends on this.
Version:
The first number is the major version.
The second number is the minor version.
The third number is the bug fix version.
You can add on either through the command line or manually editing the ‘package.json’ file.
Command line: npm install <package-name></package-name>
What happens when you add a dependency to a package with npm?
It gets stored in the ‘package.json’ file. It creates a node.modules directory and adds a line in your package.json. It goes to the npm registry and adds it to the node.modules file.
What are some other popular package managers?
Yarn and PNPM
What is Express useful for?
Implementing the HTTP endpoints for web applications. Help manage routes.
How does Express fit into a full-stack web application?
It is on the server side and it does the communication for the backend and the frontend.
It manages the HTTP messages.
How do you add ‘express’ to your package dependencies?
Writing ‘npm install express’ in your command line
What Express application method starts the server and binds it to a network ‘port’?
The listen method(). A port is endpoint of communication in an operating system.
What is Express middleware?
It is a set of functions in the Express.js web application framework that are executed in between the processing of an incoming HTTP request and the generation of an HTTP response
What is Express middleware useful for?
It can be used to perform various tasks such as logging, authentication, parsing incoming data, and serving static files, among others.
It is in between with request coming in and response coming out.
How do you mount a middleware with an Express application?
app.use and pass in a function
Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?
request, response, next
What is an API endpoint?
An API endpoint is a specific location or URL within an API (Application Programming Interface) that is used to access and interact with its functionality.
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?
It let’s the server know what the client wants