/Contact-List-Backend-Practice

Created Using NodeJS, ExpressJS and MongoDB

Primary LanguageJavaScript

Definitions

set() method:

This method is used to set various configuration options for the Express application. In this case, it is used to set the 'views' option.

join() Method:

path.join() is a method from the path module that is used to construct file paths in a platform-independent way.

The Request and Response Cycle:

As we start to build out web applications, it is important to be able to visualize the way information flows through the system; typically called the Request/Response Cycle.

First a user gives a client a URL, the client builds a request for information (or resources) to be generated by a server. When the server receives that request, it uses the information included in the request to build a response that contains the requested information. Once built, that response is sent back to the client in the requested format, to be rendered to the user.

It is our job as web developers to build out and maintain servers that can successfully build responses based on standardized requests that will be received. But, what does a standard request look like? We need to know that before we can start building servers that will respond successfully.

The standard, or protocol we use is HTTP.

HTTP Requests and Responses:

The HyperText Transfer Protocol gives us rules about how messages should be sent around the Internet. The system that initiates a connection sends a “request”, and the system the answers sends a “response”.

HTTP Request:

When a “client” (like a web browser) retrieves information, it sends a payload of data to a server as a “request”. This request has many parts, but for now we are going to focus on the verb and path.

HTTP Request Methods:-

GET: The GET method requests a representation of the specified resource. Requests using GET should only retrieve data.

HEAD: The HEAD method asks for a response identical to a GET request, but without the response body.

POST: The POST method submits an entity to the specified resource, often causing a change in state or side effects on the server.

PUT: The PUT method replaces all current representations of the target resource with the request payload.

DELETE: The DELETE method deletes the specified resource.

CONNECT: The CONNECT method establishes a tunnel to the server identified by the target resource.

OPTIONS: The OPTIONS method describes the communication options for the target resource.

TRACE: The TRACE method performs a message loop-back test along the path to the target resource.

PATCH: The PATCH method applies partial modifications to a resource.

Query Parameter:

The "Query Parameter" is the variable whose value is passed in the URL in the form of key-value pair at the end of the URL after a question mark (?). For example, www.geeksforgeeks.org?name=abc where, ‘name’ is the key of query parameter whose value is ‘abc’.