To generate newMessage, we are going to make a separate file that we load into server.js with a method we call instead of defining the object. Inside the server folder, we'll make a new directory called utils.
Inside utils we'll make a file called message.js. This will store our utility functions related to messaging, and in our case, we'll make a new one called generateMessage. Let's make a variable called generateMessage. This is going to be a function and will take the two arguments I talked about earlier, from and text:
var generateMessage = (from, text) => { };
It will then return an object just like the objects we pass in as the second argument to emit in server.js. Now all ...