DA0-DA0 / discord-notifier-cf-worker

Cloudflare Worker to power the DAO DAO Discord Notifier.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

discord-notifier-cf-worker

A Cloudflare Worker that sends Discord notifications for DAO DAO DAOs.

Used template for Cosmos wallet authentication to authenticate requests via a Cosmos wallet signature.

Development

Run locally

npm run dev
# OR
wrangler dev --local --persist

Configuration

  1. Copy wrangler.toml.example to wrangler.toml.

  2. Create KV namespaces for production and development:

npx wrangler kv:namespace create NONCES
npx wrangler kv:namespace create NONCES --preview

npx wrangler kv:namespace create WEBHOOKS
npx wrangler kv:namespace create WEBHOOKS --preview
  1. Update the binding IDs in wrangler.toml:
kv-namespaces = [
  { binding = "NONCES", id = "<INSERT NONCES_ID>", preview_id = "<INSERT NONCES_PREVIEW_ID>" },
  { binding = "WEBHOOKS", id = "<INSERT WEBHOOKS_ID>", preview_id = "<INSERT WEBHOOKS_PREVIEW_ID>" },
]
  1. Configure variables in wrangler.toml:
[vars]
DISCORD_CLIENT_ID = "<VALUE>"
  1. Configure secrets:
echo <VALUE> | npx wrangler secret put DISCORD_CLIENT_SECRET
echo <VALUE> | npx wrangler secret put DISCORD_BOT_TOKEN
echo <VALUE> | npx wrangler secret put NOTIFY_API_KEY

Deploy

wrangler publish
# OR
npm run deploy

Architecture

The WEBHOOKS KV store maps chainId:daoAddress:walletPublicKey:webhookId to a webhook object.

About

Cloudflare Worker to power the DAO DAO Discord Notifier.


Languages

Language:TypeScript 100.0%