Zum Inhalt

Notification operations

Web push and email escalation for TxRide use VAPID keys and a dedicated notifications worker.

Generate VAPID keys

bun run vapid:generate
bun run vapid:generate --format json
bun run vapid:generate --subject mailto:no-reply@txride.gra.one

The command prints the key pair and a short paste hint. It does not write env files — copy the output into .env / .env.prod (or your secret store) yourself.

Output formats:

  • env (default): KEY=value lines ready to paste
  • json: machine-readable key pair
  • compose: YAML-style lines for compose snippets

Variables:

  • VAPID_PUBLIC_KEY / VAPID_PRIVATE_KEY / VAPID_SUBJECT — API and notifications-worker
  • VITE_VAPID_PUBLIC_KEY — same as the public key; required at frontend build time

Staging / production

  1. Generate keys once per environment and store them in the deployment secret store (or .env.prod).
  2. Pass VAPID_PUBLIC_KEY, VAPID_PRIVATE_KEY, and VAPID_SUBJECT into the api and notifications-worker services.
  3. Pass VITE_VAPID_PUBLIC_KEY as a build arg for Dockerfile.web / the frontend service (Vite inlines it at build time).
  4. Set PUBLIC_WEB_URL to the public SPA origin used in email deep links.
  5. Optionally set NOTIFICATION_ESCALATION_GRACE_MINUTES (default 1440 = 24h).

Key rotation

Rotating VAPID keys invalidates every stored PushSubscription. After rotation:

  1. Redeploy API/worker with the new private key and rebuild the frontend with the new public key.
  2. Ask users to re-enable push in profile settings so the browser creates a subscription signed for the new application server key.
  • email.send — immediate and digest emails
  • Escalation scan — scheduled in the notifications worker (bun run dev:worker locally)

Push message delivery itself is tracked separately (issue #43); this branch only stores subscriptions and ships PWA/VAPID groundwork.