Skip to content

Instantly share code, notes, and snippets.

@rajivnarayana
Created March 21, 2022 05:41
Show Gist options
  • Save rajivnarayana/d8d8354327a6693121aefdcc3295bd44 to your computer and use it in GitHub Desktop.
Save rajivnarayana/d8d8354327a6693121aefdcc3295bd44 to your computer and use it in GitHub Desktop.
Webhook to grab user creation event
const express = require("express");
const bodyParser = require('body-parser');
// create application/json parser
const jsonParser = bodyParser.json();
const app = express();
app.use(jsonParser);
app.post("/webhooks/users/create", (req, res) => {
res.status(200).send("OK");
const { event: {data: { new: createdUser }}} = req.body;
console.log(`Sending email to ${createdUser.email}`);
});
const PORT = process.env.PORT || 8500;
app.listen(PORT, (err) => {
if (err) {
console.error("Could not start server: ", err);
return;
}
console.log(`Server listening on port ${PORT}`);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment