Aggiunge newsletter custom con D1, double opt-in e invio campagne.
Attiva il form footer, API subscribe/confirm/unsubscribe e endpoint admin protetti, riusando Resend per le email. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
36
README.md
36
README.md
@ -89,6 +89,42 @@ Indirizzi consigliati portale:
|
||||
- `careers@nexstudio.ai`
|
||||
- `no-reply@nexstudio.ai` (solo invio comunicazioni/newsletter, non destinazione inbound)
|
||||
|
||||
## Configurazione newsletter
|
||||
|
||||
Sistema custom su Cloudflare D1 + Resend (double opt-in).
|
||||
|
||||
Variabili server:
|
||||
|
||||
- `NEWSLETTER_MODE` (`dev` oppure `live`; se assente usa `CONTACT_FORM_MODE`)
|
||||
- `NEWSLETTER_RESEND_API_KEY` (fallback: `CONTACT_FORM_RESEND_API_KEY`)
|
||||
- `NEWSLETTER_FROM_EMAIL` (fallback: `CONTACT_FORM_FROM_EMAIL`, consigliato `no-reply@nexstudio.ai`)
|
||||
- `NEWSLETTER_NOTIFY_TO_EMAIL` (notifiche admin; fallback: `CONTACT_FORM_TO_EMAIL`)
|
||||
- `NEWSLETTER_ADMIN_TOKEN` (Bearer token per endpoint admin)
|
||||
- `NEWSLETTER_TURNSTILE_SECRET_KEY` (opzionale; fallback: `CONTACT_TURNSTILE_SECRET_KEY`)
|
||||
- `PUBLIC_SITE_URL` (origine usata nei link di conferma/disiscrizione)
|
||||
|
||||
Endpoint pubblici:
|
||||
|
||||
- `POST /api/newsletter/subscribe` — iscrizione (form footer)
|
||||
- `GET /api/newsletter/confirm?token=…` — conferma double opt-in
|
||||
- `GET|POST /api/newsletter/unsubscribe?token=…` — disiscrizione
|
||||
|
||||
Endpoint admin (header `Authorization: Bearer <NEWSLETTER_ADMIN_TOKEN>`):
|
||||
|
||||
- `GET /api/newsletter/admin/subscribers?status=active|pending|unsubscribed`
|
||||
- `POST /api/newsletter/admin/send` — body JSON `{ "subject", "text", "html?", "dryRun?" }`
|
||||
|
||||
Database:
|
||||
|
||||
- D1 `nexstudio-newsletter` (binding `NEWSLETTER_DB`)
|
||||
- Migrazioni in `migrations/`
|
||||
- `npm run db:migrate:local` / `npm run db:migrate:remote`
|
||||
|
||||
Comportamento:
|
||||
|
||||
- `dev`: accetta submit e logga (senza D1/Resend obbligatori)
|
||||
- `live`: scrive su D1, invia email di conferma via Resend, richiede binding D1
|
||||
|
||||
## Deploy Cloudflare
|
||||
|
||||
Impostazioni consigliate:
|
||||
|
||||
Reference in New Issue
Block a user