A Cloudflare Worker with a Cron Trigger (* * * * *). Every minute it:
GET {APP_URL}/api/healthwakes the app if a free instance is asleep (cold starts take about 30–60 s; the Worker waits up to 90 s).POST {APP_URL}/api/internal/outbox?run=inlinewithAuthorization: Bearer {CRON_SECRET}makes the web instance do the background work itself, once: deliver queued email and webhooks, send loan reminders and overdue escalations, open scheduled cycle counts, reconcile pending payments and run the retention purge.
That is all a free web-only deployment needs. When a worker and beat run
elsewhere, set the Worker variable INLINE=false: it then only queues work
(/api/internal/outbox and /api/internal/jobs) for that worker. Both paths
are safe to run at once: outbox rows, reminders and jobs are claimed
atomically. The VPS stack ships its own worker and beat and does not need
this Worker.
This folder is a separate package: it is excluded from the app's TypeScript,
ESLint, Vitest and Docker build, and its only dependency is wrangler.
The root dependency audit does not cover this lockfile. The quality workflow
installs and audits it separately, then bundles it with npm run check in a
Git-visible source copy with an empty user profile and metrics disabled.
That check has no Cloudflare credentials and does not deploy the Worker.
cd deploy/cloudflare-cron npm ci npx wrangler login npx wrangler secret put APP_URL # e.g. https://inventory.example.org (https, no trailing slash) npx wrangler secret put CRON_SECRET # the same value as the app's CRON_SECRET npx wrangler deploy
wrangler.toml sets workers_dev = false, so the Worker has no public URL.
It only runs on its schedule.
npx wrangler tailstreams logs. Expecthealth 200andoutbox 200every minute (plusjobs 204withINLINE=false). Only status codes are logged.404from outbox or jobs:CRON_SECRETdiffers from the app's value.outbox 500: the app could not run the outbox (database or SMTP). Check the app logs and Admin → Outbox.- After rotating the app's
CRON_SECRET, runwrangler secret put CRON_SECRETagain. npm run checkbundles the Worker without deploying it.
Cloudflare's free Workers plan allows 100,000 requests a day; this Worker uses about 1,440 scheduled runs a day.