When I delete a file, I’m getting a response, but when I use FILE_COMMENT or FILE_UPDATE, I’m not getting a response. My code is below. Am I doing something wrong or this is broken? Appreciate any help!
import express from "express";
import bodyParser from "body-parser";
import crypto from "crypto";
import fetch from "node-fetch";
import ngrok from "ngrok";
const PORT = 3000;
const app = express();
const passcode = crypto.randomBytes(48).toString("hex");
app.use(bodyParser.json());
app.post("/", (request, response) => {
console.log("helo");
if (request.body.passcode === passcode) {
console.log("Posted");
console.log(request.body);
const { file_name, timestamp } = request.body;
console.log(`${file_name} was updated at ${timestamp}`);
response.sendStatus(200);
} else {
response.sendStatus(403);
}
});
app.listen(PORT, () => console.log(` Server running on port ${PORT}`));
ngrok.connect(PORT).then(async (endpoint: any) => {
const params: any = {
event_type: "FILE_COMMENT",
team_id: "1201202467225990766",
passcode: passcode,
endpoint,
};
const options = {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Figma-Token": "figd_xaoeUzYV5187C7uKfLUZdlBhg7V_RgAA1IpIfwud",
},
body: JSON.stringify(params),
};
const response = await fetch("https://api.figma.com/v2/webhooks/", options);
const json = await response.json();
console.log(json);
});