Environment variables

  • RESEND_API_KEY, RESEND_FROM (Programs email)
  • TURNSTILE_SECRET, TURNSTILE_SITE_KEY (optional)
  • TOKEN_TTL_DAYS (default 30)
  • MIXPANEL_PROJECT_TOKEN, MIXPANEL_API_HOST, MIXPANEL_ENV, TOKEN_PEPPER (optional)
  • N8N_BASE (required for Internal calendar proxy)

Hardcoded base URL

  • Server and client code build links using https://calendar.ihnyc-rc.org.
  • If the domain changes, update both functions/api/subs/*.ts and public/subscribe-programs.js.
  • Verify link TTL: 30 minutes (VERIFY_TTL_MIN)
  • Cooldown per email: 60 seconds (COOLDOWN_SEC)
  • Token TTL: TOKEN_TTL_DAYS

Common failure modes

  • Missing bindings: SUBS_DB, CAL_BUCKET, or N8N_BASE 500
  • Turnstile misconfiguration verification errors or disabled submit button
  • Resend errors magic link request fails
  • Calendar disabled /api/subs/verify and /cal/programs.ics return 403/404

Admin operations

  • Revoke access: POST /api/admin/revoke disables subscriber and revokes tokens
  • Re-enable: POST /api/admin/enable
  • Stats: GET /api/admin/stats

Observability

  • Access attempts are logged in calendar_access_log with status, ua, and ip_hash.
  • Mixpanel captures request and delivery milestones.