Skip to content

Cloudflare Workers

Deploy tripplan.ing to Cloudflare Workers with D1, KV, and R2 for a globally distributed production environment.

Prerequisites

  • Cloudflare account with Workers, D1, KV, and R2 enabled
  • wrangler CLI installed (npm install -g wrangler)
  • GitHub repository with Actions enabled

Cloudflare resources

A single Worker serves all events. Resources are shared — no per-event provisioning:

ResourceTypePurpose
WorkerCloudflare WorkerSvelteKit application
D1DatabaseAll platform and event data
KVKey-value storeSessions, OTP codes
R2Object storagePhotos, documents

Event isolation is enforced by event_id scoping in the database, not by separate resources.

Resource configuration

Resources are configured in apps/event-site/wrangler.toml:

toml
name = "tripplan"
compatibility_flags = ["nodejs_compat"]

[[d1_databases]]
binding = "DB"
database_name = "tripplan-db"
database_id = "your-d1-database-id"

[[kv_namespaces]]
binding = "KV"
id = "your-kv-namespace-id"

[[r2_buckets]]
binding = "R2"
bucket_name = "tripplan-storage"

The nodejs_compat compatibility flag is required for dependencies that use Node.js built-in modules.

Adapter

tripplan.ing uses @sveltejs/adapter-cloudflare (not the deprecated adapter-cloudflare-workers):

javascript
// svelte.config.js
import adapter from '@sveltejs/adapter-cloudflare';

export default {
  kit: {
    adapter: adapter()
  }
};

DNS and domains

Each event gets a subdomain (e.g., reunion.tripplan.ing). Configure DNS:

  1. Add a CNAME or A record pointing the subdomain to your Worker
  2. The Worker resolves the hostname to an event via platform_event_domains
  3. Wildcard DNS (*.tripplan.ing) simplifies multi-event routing

Or use custom domains — add them to platform_event_domains and configure DNS accordingly.

Go-live checklist

Pre-deploy

  • [ ] npm run check passes
  • [ ] npm test passes
  • [ ] npm run -w @tripplan/event-site build:workers succeeds
  • [ ] GitHub Environments configured (see Environment & Secrets)

GitHub Environment setup

  1. Create development and production environments in GitHub
  2. Populate with required variables and secrets
  3. Verify CF_DEPLOY_API_TOKEN has deploy permissions

Deploy

  1. Push to main (or trigger .github/workflows/apps-ci.yml manually)
  2. Confirm all CI stages pass: checks, build, migration, secret sync, deploy

Post-deploy validation

Verify each area works:

CheckHow
Platform UISign in at /platform as an operator
Event creationCreate a test event at /platform/events/create
Event homepageVisit the event's subdomain
Auth OTPSign in with an allowed email
RSVPSubmit and edit a test RSVP
PaymentsComplete a Stripe test checkout
WebhookVerify payment status updates after checkout
AdminAccess /admin on the event subdomain
PhotosUpload and view a test photo

Docs Worker

The docs site has a separate deployment:

  1. Run .github/workflows/docs-deploy.yml
  2. Verify docs load at the configured URL

Rollback

If a deployment causes issues:

  1. Re-deploy the previous known-good git SHA
  2. Run migration checks to confirm schema compatibility
  3. If an event is unhealthy, suspend it via the platform UI while investigating
  4. Record incident details in the platform audit log

Released under the MIT License.