binding.ts
This file
Path
apps/platform/src/auth/mailer/binding.ts
29 lines · 778 bytes · TypeScript
Last changed by
Sign people in by a proven email, with a display name, and Google's emailoscabrielbefore adoption125964c
History of this fileTake it
Sign people in by a proven email, with a display name, and Google's emailoscabrielbefore adoption125964c
lines 1–29why, one step back1// Cloudflare Email Service's `send_email` binding. The sending domain is2// the brand's, onboarded for sending on the account.3import { Brand } from "@repo/brand";4import { Effect, Layer } from "effect";56import { MailFailed, Mailer } from "../mailer.ts";78export const MAIL_FROM = {9 email: `no-reply@${Brand.domain}`,10 name: Brand.name,11} as const;1213export const MailerBinding = (binding: SendEmail) =>14 Layer.succeed(15 Mailer,16 Mailer.of({17 send: (mail) =>18 Effect.tryPromise({19 catch: () => new MailFailed(),20 try: () =>21 binding.send({22 from: MAIL_FROM,23 subject: mail.subject,24 text: mail.text,25 to: mail.to,26 }),27 }).pipe(Effect.asVoid),28 })29 );