lib/util/responseTranslator.js
function mapMongoEventsToResponseObj(events){

  // Base response, regardless of whether we have alerts or not
  var res = {"list":[],"status":"ok"};

  // Filter and add alerts to response if we have them
  
  if (events){
    res.list = _.map(events, function(event){
      var ev = event.toJSON();
      ev.message = event.details ? event.details.message || " " : " ";
      ev.category = event.eventClass;
      ev.severity = event.eventLevel;
      ev.guid = event._id;
      ev.eventDetails = ev.details ||{};
      return ev;
    });
  }
  // Return the response
  return res;
}
function mapMongoEventsToResponseObj(events){

  // Base response, regardless of whether we have alerts or not
  var res = {"list":[],"status":"ok"};

  // Filter and add alerts to response if we have them
  
  if (events){
    res.list = _.map(events, function(event){
      var ev = event.toJSON();
      ev.message = event.details ? event.details.message || " " : " ";
      ev.category = event.eventClass;
      ev.severity = event.eventLevel;
      ev.guid = event._id;
      ev.eventDetails = ev.details ||{};
      return ev;
    });
  }
  // Return the response
  return res;
}
function mapMongoEventsToResponseObj ( events ) { // Base response, regardless of whether we have alerts or not var res = { "list" : [ ] , "status" : "ok" } ; // Filter and add alerts to response if we have them if ( events ) { res . list = _ . map ( events , function ( event ) { var ev = event . toJSON ( ) ; ev . message = event . details ? event . details . message || " " : " " ; ev . category = event . eventClass ; ev . severity = event . eventLevel ; ev . guid = event . _id ; ev . eventDetails = ev . details || { } ; return ev ; } ) ; } // Return the response return res ; }
Events from Mongo should not be coupled to response format
Map query result Events to single response object as it is defined
@param alerts
@returns {{}}
Events from Mongo should not be coupled to response format Map query result Events to single response object as it is defined