code: function middleware(cb) {
    if (!cb || typeof cb !== 'function') {
      throw new Error('callback must be a function.');
    }
  
    return (req, res) => {
      if (!req || !req.body || !req.body.Metadata) {
        return cb(new Error('callback payload is invalid.'), req, res, false);
      }
  
      const contentSignature = req.headers['x-content-signature'];
      const callbackBody = req.body;
  
      let parsedEntity;
      try {
        parsedEntity = JSON.parse(callbackBody.Entity);
      } catch (parseErr) {
        return cb(parseErr, req, res, false);
      }
  
      verifyCallback(callbackBody, contentSignature)
        .then(verified => {
          /* eslint-disable promise/no-callback-in-promise */
          return cb(null, req, res, verified, Object.assign(callbackBody, {Entity: parsedEntity}));
        })
        .catch(err => {
          return cb(err, req, res, false);
        });
    };
  }
docs: Express style middleware
  @example
  app.post('/your/api', cw.utils.middleware((err, req, res, verified, payload) => {
  if (err) {
  //handle error
  res.status(500).end();
  } else if (!verified) {
  // send 403 on verification failure
  res.status(403).end();
  } else {
  res.status(200).end()
  }
  const {action, id} = req.query;
  // do something with the payload
  }));
  
  @param {function} cb callback(err, req, res, verified, payload)