Cloudflare Workers + D1

Deploy Calends to your own Cloudflare account — one-click or from the command line — with the D1 database, the cron trigger and optional email reminders.

On this page

Deploy Calends to your Cloudflare account with D1, scheduled jobs and optional email reminders.

Calends is a Cloudflare Worker: the front end is served as the Worker’s static assets, data lives in D1 (SQLite), and reminders and exchange rates run on a cron trigger. Usage and cost depend on your Cloudflare account’s current plan and quotas.

Requirements

  • A Cloudflare account;
  • for command-line deploys, Node.js 24 and git.

One-click deploy

Open Deploy to Cloudflare and follow the steps to copy the repository into your GitHub account and deploy it.

Then, in the Cloudflare dashboard, open the Worker’s Settings → Variables and Secrets and add a secret named SETUP_TOKEN with a long random value. Without it you can’t set a password.

Command-line deploy

  1. Clone and install:

    Terminal window
    git clone https://github.com/imetn/calends && cd calends
    npm ci
  2. Sign in to Cloudflare and check that npx wrangler whoami shows your account:

    Terminal window
    npx wrangler login
  3. Set the setup token:

    Terminal window
    npx wrangler secret put SETUP_TOKEN

    openssl rand -base64 24 is one way to generate a random value.

  4. Deploy:

    Terminal window
    npm run deploy
  5. Open https://calends.<your-subdomain>.workers.dev, enter the setup token and choose your password.

npm run deploy does the following:

  1. generates the migration and translation files, type-checks, and builds the front end with Vite;
  2. deploys the Worker with wrangler deploy. On the first deploy, a D1 database named calends is created automatically — no database_id to fill in;
  3. applies all migrations to the remote database.

The Worker also checks for and applies missing migrations the first time each instance handles a request, so one-click deployments work too.

wrangler.jsonc

The wrangler.jsonc in the repository is ready to go:

Setting What it does
assets Front-end assets. /api/*, /cal/* and /mcp go to the Worker first; other paths fall back to the single-page app.
d1_databases Binding DB, database calends.
triggers.crons */15 * * * *: checks reminders and retries every 15 minutes. FX maintenance runs at UTC hour boundaries and refreshes rates older than 20 hours.
observability Workers logs on, so reminder results and migrations show up in the dashboard.

Email reminders

Email reminders use Cloudflare Email Sending. Skip this section if you don’t need email; no other channel needs server-side configuration.

  1. Enable email sending for your domain in Cloudflare and verify a sender address, such as calends@example.com.

  2. In wrangler.jsonc, uncomment and edit these two entries:

    "send_email": [{ "name": "EMAIL", "allowed_sender_addresses": ["calends@example.com"] }],
    "vars": { "SITE_URL": "https://calends.example.com", "MAIL_FROM": "calends@example.com", "MAIL_FROM_NAME": "Calends" },
  3. Deploy again: npm run deploy.

  4. Under Settings → Notification channels, add an email channel with your address and click Test.

Custom domain

See Custom domain and HTTPS.

Cost

Usage includes Workers requests, D1 reads, writes and storage, Cron, optional R2 storage/operations, and email sending. Check actual usage and current quotas in your Cloudflare dashboard. The built-in assistant uses your selected provider, billed separately from Cloudflare.

File storage

File uploads require a private R2 bucket bound as FILES; without it uploads are disabled and other ledger features continue to work. Create it with npx wrangler r2 bucket create calends-files, add "r2_buckets": [{ "binding": "FILES", "bucket_name": "calends-files" }] to your Wrangler configuration, keep public access disabled, and redeploy. FILES_LIMIT_MB sets total capacity in MB (default 300); each file is limited to 10 MB.