reading-note

https://eng-ehabsaleh.github.io/reading-note/

View on GitHub

describe what each group of status code represents:

100 - 199 PermalinkThese are informational status codes; they usually tell the client that the header part of the request has been received and the server will try to comply with a transmission demand of the client.

200 - 299 PermalinkThese are the success codes. They tell the client that its request was accepted. In case of asynchronous processing of a request (202)

300 - 399 PermalinkThese are redirection codes. They tell the client that the resource they are requesting isn’t available at the expected location anymore.

400 - 499 PermalinkThese are the client error codes. They are all about invalid requests a client sent to a server

500 - 599 PermalinkThese are the server error codes. Often they indicate problems with overwhelmed servers or unreachable servers behind proxies, but sometimes they can be directly related to client requests that trigger error exceptions on the server.

What is a status code 202?

The HyperText Transfer Protocol (HTTP) 202 Accepted response status code indicates that the request has been accepted for processing, but the processing has not been completed; in fact, processing may not have started yet

What is a status code 308?

The HyperText Transfer Protocol (HTTP) 308 Permanent Redirect redirect status response code indicates that the resource requested has been definitively moved to the URL given by the Location headers. … Note: Some Web applications may use the 308 Permanent Redirect in a non-standard way and for other purposes

What code would you use if an update didn’t return data to a client?

The difference lies in the amount of data the client has to send to the backend. … 204 No Content - A proper code for updates that don’t return data to the client, for example when just saving a currently edited document. 202 Accepted - If the update is done asynchronous, this code can be used

What code would you use if a resource used to exist but no longer does?

However, the “409 Conflict” is the best existing answer code (as pointed by @Wrikken), maybe including a Location header pointing to the existing resource. IMHO, “307 Temporary Redirect” is the real temporary redirec

What is the ‘Forbidden’ status code?

The HTTP 403 Forbidden client error status response code indicates that the server understood the request but refuses to authorize it. This status is similar to 401 , but in this case, re-authenticating will make no difference

Why do we need to pull our MongoDB database string out of our server and put it into our .env?

to hide the senstive data

What is middleware?

Middleware is software that provides common services and capabilities to applications outside of what’s offered by the operating system

What does app.use(express.json()) do?

it decrpt the encyrited data which sent in the body of the request

What does the /:id mean in a route?

it is a unique id which will be generated auto once you add a data to the db

What is the difference beween PUT and PATCH

The main difference between the PUT and PATCH method is that the PUT method uses the request URI to supply a modified version of the requested resource which replaces the original version of the resource, whereas the PATCH method supplies a set of instructions to modify the resource

Your schemas can define default values for certain paths. If you create a new document without that path set, the default will kick in.

What does a 500 error status code mean?

The HyperText Transfer Protocol (HTTP) 500 Internal Server Error server error response code indicates that the server encountered an unexpected condition that prevented it from fulfilling the request. This error response is a generic “catch-all” response

What is the difference between a status 200 and a status 201

The 200 status code is by far the most common returned. It means, simply, that the request was received and understood and is being processed. A 201 status code indicates that a request was successful and as a result, a resource has been created (for example a new page)