This Worker receives webhook POST requests, validates a shared secret, reads emails from payload JSON, and sends notification emails using Brevo.
npm install --include=optional --ignore-scriptsWhy this command:
workerdrequires optional platform packages.wrangleralso pullssharpas optional, and on Node 25 it may fail native build.--ignore-scriptsavoids thesharpbuild while keepingworkerdbinaries installed.
Recommended runtime: Node 22 LTS.
Copy and edit:
cp .dev.vars.example .dev.varsSet values in .dev.vars:
WEBHOOK_SECRET= your incoming webhook secretBREVO_API_KEY= your Brevo API keyBREVO_SENDER_EMAIL= sender identity verified in BrevoBREVO_SENDER_NAME= optional sender display name
npm run devcurl --request POST "http://127.0.0.1:8787" \
--header "content-type: application/json" \
--header "x-webhook-source: kuppihub-db-trigger" \
--header "x-webhook-secret: hi" \
--data '{
"title": "Fluid Dynamics P1",
"emails": [
"nipunsgeeth@gmail.com",
"nsangeeth920@gmail.com",
"sangeethnipun385@gmail.com"
],
"is-kuppi": true,
"is_kuppi": true,
"video_id": 159,
"description": "Kuppi 1, Batch 23",
"module_code": "CE1023",
"module_name": "Fluid Mechanics",
"language-code": "si",
"language_code": "si"
}'Set production secrets:
npx wrangler secret put WEBHOOK_SECRET
npx wrangler secret put BREVO_API_KEY
npx wrangler secret put BREVO_SENDER_EMAIL
npx wrangler secret put BREVO_SENDER_NAMEDeploy:
npm run deploy- The Worker requires valid
x-webhook-secret. - If
WEBHOOK_SOURCEis set inwrangler.toml, the headerx-webhook-sourcemust match it. - Invalid or empty recipient lists are rejected.