Skip to content

Kuppihub/Email-Notify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Email Notify Worker (Cloudflare + Brevo)

This Worker receives webhook POST requests, validates a shared secret, reads emails from payload JSON, and sends notification emails using Brevo.

1) Install

npm install --include=optional --ignore-scripts

Why this command:

  • workerd requires optional platform packages.
  • wrangler also pulls sharp as optional, and on Node 25 it may fail native build.
  • --ignore-scripts avoids the sharp build while keeping workerd binaries installed.

Recommended runtime: Node 22 LTS.

2) Configure local env

Copy and edit:

cp .dev.vars.example .dev.vars

Set values in .dev.vars:

  • WEBHOOK_SECRET = your incoming webhook secret
  • BREVO_API_KEY = your Brevo API key
  • BREVO_SENDER_EMAIL = sender identity verified in Brevo
  • BREVO_SENDER_NAME = optional sender display name

3) Run locally

npm run dev

4) Test request

curl --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"
  }'

5) Deploy

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_NAME

Deploy:

npm run deploy

Notes

  • The Worker requires valid x-webhook-secret.
  • If WEBHOOK_SOURCE is set in wrangler.toml, the header x-webhook-source must match it.
  • Invalid or empty recipient lists are rejected.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors