docs/examples/webhook-receivers/typescript-cloudflare-worker/worker.ts
worker.ts
Deploy on Cloudflare Workers
https://pegana-hook.<account>.workers.dev — register it
in pegana.xyz/account/webhooks.
Deploy on Vercel Edge
Same logic inapp/api/pegana-hook/route.ts:
Node 18+ (Express, Fastify)
Same verification. Make sure you read the raw body before any JSON middleware:Production checklist
- Persist
alert_idin a real store (Cloudflare KV, Redis, your DB) - Pin
PEGANA_PUB_KEY_B64via secrets, not in source — easier rotation - ACK with
200(or202) within ~100ms; queue real work to a background runner - Log failed verifications with timestamp + remote IP for audit
- Poll
/v1/me/alertsas a safety net (catch deliveries that exhausted retries) - Set
Content-Typeon your response — some load balancers strip empty bodies
Why Web Crypto and not @noble/ed25519
The Web Crypto API is standardized, audited, and ships with every modern runtime
(Workers since 2023 via Secure Curves; Node since 18 via webcrypto). @noble/ed25519
is excellent and you may need it for older Node versions (<18) — but for new code,
Web Crypto is one less dependency.
Next
Rust example
axum + ed25519-dalek strict mode.
Retry policy
Failure modes, backoff, replay.