A controller can be defined as an entity that will be responsible for manipulating models and initiating the View render process with the data received from the corresponding models. In the code we have developed so far, we can see that the express router instance is used to tie functions to a corresponding route. These functions are nothing but controllers.
For every route that we create in our router, the following two parameters are necessary:
- The first parameter is the string for the route itself, which is /images/:image_id
- The second parameter is a controller function that will be executed when that route is accessed
For any route that has anything to do with images, we rely on the image controller. Likewise, any route that has anything to do with the home page relies on the home controller, and so on.
The steps we will take to define our controllers in our...