api/controllers/CommandsController.js
/**
 * Parses the requests, executes all server operations and returns the movie
 * description.
 */
Parses the requests, executes all server operations and returns the movie
description.
Parses the requests executes all server operations and returns the movie description .
async function parseRequest(movieParam, userMessage) {
  let filmDescription, movieHashCode, movieFileName, newFileName;
  if (!movieParam) {
    userMessage.message = `Wrong parameter`;
    return;
  }
  newFileName = ''.concat(uuidv1());
  try {
    movieHashCode = await getFilmHashCode(movieParam);
    movieFileName = MovieService.getFileName(movieHashCode);
    filmDescription = await readFIle(movieFileName);
    await writeFIle(newFileName, filmDescription);
    await runCommand(newFileName);
    removeFIle(newFileName);
    console.log('`n ##Movie Description found: ' + filmDescription);
    if (!filmDescription) {
      userMessage.message = `No film description found - try to repeat please`;
      return;
    }
    return filmDescription;
  } catch (error) {
    console.log('ERROR :' + error);
    userMessage.serverError = true;
    userMessage.message = `Error during movie search execution, try again `;
    return;
  }
}
async function parseRequest ( movieParam , userMessage ) { let filmDescription , movieHashCode , movieFileName , newFileName ; if ( ! movieParam ) { userMessage . message = ` ` ; return ; } newFileName = '' . concat ( uuidv1 ( ) ) ; try { movieHashCode = await getFilmHashCode ( movieParam ) ; movieFileName = MovieService . getFileName ( movieHashCode ) ; filmDescription = await readFIle ( movieFileName ) ; await writeFIle ( newFileName , filmDescription ) ; await runCommand ( newFileName ) ; removeFIle ( newFileName ) ; console . log ( '`n ##Movie Description found: ' + filmDescription ) ; if ( ! filmDescription ) { userMessage . message = ` ` ; return ; } return filmDescription ; } catch ( error ) { console . log ( 'ERROR :' + error ) ; userMessage . serverError = true ; userMessage . message = ` ` ; return ; } }
Parses the requests, executes all server operations and returns the movie
 description.
Parses the requests executes all server operations and returns the movie description .
// NO INPUT