Created
March 21, 2022 05:41
-
-
Save rajivnarayana/d8d8354327a6693121aefdcc3295bd44 to your computer and use it in GitHub Desktop.
Webhook to grab user creation event
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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