reading-notes

Think you might be in the wrong place? Go home!

In your own words, describe what each group of status code represents:

403 (Forbidden) Indicates the client lacks necessary permissions.

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

Storing sensitive information, such as database connection strings, in the .env file adds a layer of security. It keeps sensitive data separate from the codebase and allows developers to use different configurations for development, testing, and production environments without modifying the code.

What is middleware?

Middleware is software that acts as a bridge between an application and its database, server, or other components. In the context of web development, middleware functions have access to the request and response objects, and they can perform tasks such as modifying the request, response, or executing additional code before reaching the final route handler.

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

This middleware in Express.js is used to parse incoming JSON requests. It enables the server to understand and work with JSON data sent in the request body, making it accessible through req.body in route handlers.

What does the /:id mean in a route?

It represents a route parameter in Express.js. The value specified in the URL at the position of :id is captured and made available as req.params.id in the route handler. This allows dynamic handling of requests with varying IDs.

What is the difference between PUT and PATCH?

How do you make a default value in a schema?

In a MongoDB schema, you can set a default value for a field using the default property. For example:

const UserSchema = new Schema({
  name: {
    type: String,
    default: 'John Doe',
  },
});

What does a 500 error status code mean?

A 500 Internal Server Error status code indicates that the server encountered an unexpected condition that prevented it from fulfilling the request. It is a generic error message when the server encounters an error not specifically handled by the application.

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

Information gathered using ChatGPT