async function cancel(req, res) {
  const { models, appLog, webhooks, body } = req;

  const { connectionId } = body;

  const id = req.params.batchId;

  const connection = await models.connections.findOneById(connectionId);
  const batch = await models.batches.findOneById(id);

  if (batch.status !== 'error') {
    if (!connection.isAsynchronous) {
      return res.utils.error(
        'Cancel batch is only available to drivers that support cancellation'
      );
    }

    await cancelBatch(models, webhooks, batch.id).catch((error) =>
      appLog.error(error)
    );
  }
  const updatedBatch = await models.batches.findOneById(id);
  appLog.trace(updatedBatch);
  return res.utils.data(updatedBatch);
}
Cancel batch
@param {Req} req
@param {Res} res