title: Node and Express: How to implement basic webhook server
body: <p>I'm having a surprisingly hard time finding tutorials. I'm new to webhooks and have not used or seen them, beyond some basic descriptions of how they're supposed to work.</p>
  
  <p>Our use-case for this is updating users of our APIs when there are new records. Since we're using Kafka and have settled on "eventual consistency" , another use might be to notify them of errors when records could not be read/written properly from the Kafka stream.</p>
  
  <p>So, the basic concept as far as I can see:</p>
  
  <pre><code>const express = require("express");
  const router = express.Router();
  
  const processSomething = callback =&gt; {
      setTimeout(callback, 20000);
  }
  
  router.post("/hook", (req, res, next) =&gt; {
      processSomething(() =&gt; {
          res.status(200).send({
              id: "ABC123",
              message: "New record added!"
          });
      });
  });
  
  module.exports = router;
  </code></pre>
  
  <p>Is this essentially what I'm shooting for? Would users post to this endpoint, await a response, then post again upon getting the response so as to re-subscribe? Is there a problem with this running for a long period or even indefinitely?</p>
  
  <p>I could really use more sophisticated examples but I'm just not finding them. Most of what you find when Googling this involves integrating third-party webhooks, like Github, Slack, etc., not custom which is what I'm needing to build.</p>
  
  <p>I'm not opposed to another approach entirely, either. Just searching for the best means of notifying API users of updates and other important info.</p>