Building an Express Application Chapter 2
Response object
After receiving the request on req variable, the res object is something that we send back
as the response we want.
The properties of the response are:
send: This is used for sending a response to the views. Accessed via res.send. It
takes two parameters, the status code, and the response body.
status: If we want to send the success or failure of the application, res.status is
used. This is the HTTP status code.
redirect: res.redirect is used when we want to redirect to a certain page
rather than sending responses in other formats.
Introduction to MVC
The MVC model is essential when building applications regardless of any programming
languages. The MVC architecture makes it easy to organize our application's structure and
separate out logic parts and view parts. We can incorporate this MVC structure at any time,
even if we have completed half of our application. The best time to implement it is at the
start of any application.
As the name suggests, there are three parts to it:
Model: All of the application's business logic resides under these models. These
deal with the database. They handle all the logic parts of the application.
View: Everything that the browser renders—what users see—is handled by these
view files. It deals with whatever we send to the client.
Controller: Controllers basically connect these models and views. It is
responsible to take the logical calculations done in models to the views sections: