
This is what all it required by polar to see the webhook data. Managing with webhook data is not an issue, but how do I pair this all with appwrite functions structure so I will be able to verify the signature and get the webhook data in the first place?
import { Hono } from "hono";
import { Webhooks } from "@polar-sh/hono";
const app = new Hono();
app.post(
"/polar/webhooks",
Webhooks({
webhookSecret: process.env.POLAR_WEBHOOK_SECRET!,
onPayload: async (payload) => {
console.log("Received webhook payload:", payload);
},
})
);

Do you have something like this
https://github.com/dishwasher-detergent/kurioh/blob/main/functions/api/src/main.ts#L44-L45 https://github.com/dishwasher-detergent/kurioh/blob/main/functions/api/src/lib/utils.ts#L6
that converts the appwrite context into a context for hono?

var Webhooks = ({
webhookSecret,
onPayload,
entitlements,
...eventHandlers
}) => {
return async (c) => {
const requestBody = await c.req.text();
const webhookHeaders = {
"webhook-id": c.req.header("webhook-id") ?? "",
"webhook-timestamp": c.req.header("webhook-timestamp") ?? "",
"webhook-signature": c.req.header("webhook-signature") ?? ""
};
let webhookPayload;
try {
webhookPayload = validateEvent(
requestBody,
webhookHeaders,
webhookSecret
);
} catch (error) {
if (error instanceof WebhookVerificationError) {
return c.json({ received: false }, { status: 403 });
}
throw error;
}
await handleWebhookPayload(webhookPayload, {
webhookSecret,
entitlements,
onPayload,
...eventHandlers
});
return c.json({ received: true });
};
};

const validateEvent = (body, headers, secret) => {
const base64Secret = Buffer.from(secret, "utf-8").toString("base64");
const webhook = new Webhook(base64Secret);
try {
const parsed = webhook.verify(body, headers);
return parseEvent(parsed);
}
catch (error) {
if (error instanceof _WebhookVerificationError) {
throw new WebhookVerificationError(error.message);
}
throw error;
}
};

what does your main entry point to the function look like

What do you mean?

How is this being served by appwrites function?
Recommended threads
- coolify/appwrite ssl functions
(Sorry for m english, i'm french) Hello, i tried for 3 days to generate ssl for domain function like idfunction.appwrite.christophe-le-goff.dev. I install appwr...
- Error on updating Functions build comman...
I try to update the "build command" of one of my functions using the Console UI, but I always get an unknown server error (see screenshots). I can change other ...
- deleteDocments is not a function
Hello. At the bottom of my project's console, in the footer, I have `Version 1.7.4`. However, when I run my server side function, I am told that `databases.dele...
