function doAction(controller, request) {
  const ret = controller[request.input.action](request);

  if (!ret || typeof ret.then !== "function") {
    return kerror.reject(
      "plugin",
      "controller",
      "invalid_action_response",
      request.input.controller,
      request.input.action,
    );
  }

  return ret;
}
Execute a controller action, checking that its return
value is a Promise. If not, wraps the returned value
in a rejected Promise and returns it.

Used to make Kuzzle safe from badly implemented plugins

@param  {Object} controller
@param  {Request} request
@returns {Promise}