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=valuelines ready to pastejson: machine-readable key paircompose: YAML-style lines for compose snippets
Variables:
VAPID_PUBLIC_KEY/VAPID_PRIVATE_KEY/VAPID_SUBJECT— API and notifications-workerVITE_VAPID_PUBLIC_KEY— same as the public key; required at frontend build time
Staging / production¶
- Generate keys once per environment and store them in the deployment secret store (or
.env.prod). - Pass
VAPID_PUBLIC_KEY,VAPID_PRIVATE_KEY, andVAPID_SUBJECTinto theapiandnotifications-workerservices. - Pass
VITE_VAPID_PUBLIC_KEYas a build arg forDockerfile.web/ thefrontendservice (Vite inlines it at build time). - Set
PUBLIC_WEB_URLto the public SPA origin used in email deep links. - Optionally set
NOTIFICATION_ESCALATION_GRACE_MINUTES(default1440= 24h).
Key rotation¶
Rotating VAPID keys invalidates every stored PushSubscription. After rotation:
- Redeploy API/worker with the new private key and rebuild the frontend with the new public key.
- Ask users to re-enable push in profile settings so the browser creates a subscription signed for the new application server key.
Related queues¶
email.send— immediate and digest emails- Escalation scan — scheduled in the notifications worker (
bun run dev:workerlocally)
Push message delivery itself is tracked separately (issue #43); this branch only stores subscriptions and ships PWA/VAPID groundwork.