The "join codebar on Slack" page for codebar, running on Cloudflare Workers. Serves the form at https://slack.codebar.io, verifies submissions with Turnstile, and sends Slack invites through the legacy users.admin.invite API.
This replaces the previous Heroku app (codebar/slack-invite-automation). It keeps only the behaviour production actually used: the invite form and submission. Things with no traffic — the badge endpoint, reCAPTCHA, locale variants — are gone.
GET /serves a static form (public/index.html) with a Cloudflare Turnstile widget.POST /inviteverifies the Turnstile token, then calls Slack'susers.admin.invitewith the workspace token. Failures map to short messages: missing email, Turnstile failure, invalid email, already invited / already in team, and generic errors.- A daily scheduled check (cron, added at cutover — see comment in
wrangler.jsonc) callsusers.listwith the Slack token. On failure it posts an alert toALERT_WEBHOOK_URL. This exists because the legacy token is a consumable secret that Slack can revoke at any time.
| Variable | Purpose |
|---|---|
TURNSTILE_SECRET |
Turnstile site verification |
SLACK_TOKEN |
Legacy Slack workspace token (xoxp-) |
ALERT_WEBHOOK_URL |
Webhook for the daily health check |
The Turnstile site key sits in public/index.html. Site keys are public, so it is in git. The secret key is TURNSTILE_SECRET in the secrets table above.
npm install
npm run dev # wrangler dev, serves the local worker
npm test # three vitest suites (see below)npm test runs three suites:
vitest.config.js— the full suite: invite flow, static assets, worker wiring, scheduled health check.vitest.nosecret.config.js— proves nothing is sent to Slack when secrets are unset (fail-closed).vitest.noslack.config.js— proves the real Slack endpoint is never reached, even when secrets exist.
Pushing to main runs the test suite and, on green, deploys via wrangler-action (deploy.yml). Deploy needs CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID repository secrets, with wrangler.jsonc driving the config.
docs/superpowers/ holds the design spec and implementation plan for the rewrite, including the production analysis that decided what was in scope.