@replyke/express
Version:
Replyke: Build interactive apps with social features like comments, votes, feeds, user lists, notifications, and more.
26 lines (25 loc) • 945 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const utility_functions_1 = require("./utility-functions");
exports.default = async (req, res, payload) => {
const entityUpdatedWebhook = req.project.webhooks.entityUpdated;
if (!entityUpdatedWebhook)
return;
const sharedSecret = req.project.keys.secret?.key;
if (!sharedSecret) {
return res
.status(400)
.json({ error: "Webhook URL or secret not configured" });
}
try {
const webhookResponse = await (0, utility_functions_1.sendWebhookRequestWithHandle)(entityUpdatedWebhook, payload, sharedSecret);
if (!webhookResponse || webhookResponse.valid !== true) {
return res.status(400).json({
error: webhookResponse?.message || "Invalid entity data",
});
}
}
catch (err) {
res.status(500).json({ error: err.message });
}
};