It's started to get a little hard to read the events.controller.js file. There are a few functions in there with some code in between and the file is getting larger.

We'll be using what's known as the revealing module pattern to clean up our code a bit. This is where we return an object literal with names that map to the functions we'll need.

For instance, we are using:

Table of Contents

    // export this object
    module.exports = {
      showEvents: showEvents,
      showSingle: showSingle,
      seedEvents: seedEvents
    };
    
    function showEvents(req, res)...
    function showSingle(req, res)...
    function seedEvents(req, res)...

    This cleans up our code a bit and lets us easily view what's going on in this file.

    Chris Sevilleja

    176 posts

    Founder of Scotch.io. Google Developer Expert in Web Technologies. Slapping the keyboard until something good happens.