Controllers
A controller is nothing more than an object that contains similar logic and functionality within our application. In our project, a controller is tied directly via its functions to a corresponding route. For every route that we create in our router, two parameters are necessary. The first parameter is the string for the route itself, that 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 to do with images, we rely on the images controller. Likewise, any route that has to do with the home page relies on the home controller, and so on and so forth.
The steps we will take to define our controllers in our app are purely organizational and based on a personal preference. We created our controllers as modules so that our router wasn't a big, long convoluted mess of spaghetti code! We could have just as easily kept all of the logic contained in our controllers as functions directly within the...