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.
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.
So, the basic concept as far as I can see:
const express = require("express");const router = express.Router();const processSomething = callback => { setTimeout(callback, 20000);}router.post("/hook", (req, res, next) => { processSomething(() => { res.status(200).send({ id: "ABC123", message: "New record added!" }); });});module.exports = router;
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?
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.
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.