const express = require('express');
const app = express();
app.post(
"/webhook",
express.json({ type: "application/json" }),
(request, response) => {
const event = request.body;
switch (event.type) {
case "brand.updated":
const brand = event.data.object;
const changes = event.data.delta;
// Handle the brand updated event
console.log(`Brand updated: ${brand.domain}`);
break;
case "brand.verified":
const verifiedBrand = event.data.object;
// Handle the brand verified event
console.log(`Brand verified: ${verifiedBrand.domain}`);
break;
default:
console.log(`Unhandled event type ${event.type}`);
}
// Return a 200 response to acknowledge receipt
response.json({ received: true });
}
);
app.listen(8000, () => console.log("Running on port 8000"));