function createMessage(messageId, params, response) {
  let today = new Date();
  let time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();

  let message = new Message(
    messageId,
    params.user.trim(),
    params.message.trim(),
    time,
  );
  let messageDataFile = $path.join(messagesDir, messageId + ".json");
  fs.writeFile(messageDataFile, JSON.stringify(message), err => {
    if (err) {
      response.status(500).send(err);
    } else {
      response.redirect("/chat");
    }
  });
}
// note: need to write function if NO messages currently.
need to write function if NO messages currently.
need to write function if NO messages currently .
function createMessage(messageId, params, response) {
  let today = new Date();
  let time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
  let message = new Message(
    messageId,
    params.user.trim(),
    params.message.trim(),
    time,
  );
  let messageDataFile = $path.join(messagesDir, messageId + ".json");
  fs.writeFile(messageDataFile, JSON.stringify(message), err => {
    if (err) {
      response.status(500).send(err);
    } else {
      response.redirect("/chat");
    }
  });
}
function createMessage ( messageId , params , response ) { let today = new Date ( ) ; let time = today . getHours ( ) + ":" + today . getMinutes ( ) + ":" + today . getSeconds ( ) ; let message = new Message ( messageId , params . user . trim ( ) , params . message . trim ( ) , time , ) ; let messageDataFile = $path . join ( messagesDir , messageId + ".json" ) ; fs . writeFile ( messageDataFile , JSON . stringify ( message ) , err => { if ( err ) { response . status ( 500 ) . send ( err ) ; } else { response . redirect ( "/chat" ) ; } } ) ; }
note: need to write function if NO messages currently.
note : need to write function if NO messages currently .