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
123456789101112131415161718192021222324252627282930// Cloudflare Email Service's `send_email` binding. The sending domain is// the brand's, onboarded for sending on the account.import { Brand } from "@repo/brand";import { Effect, Layer } from "effect";
import { MailFailed, Mailer } from "../mailer.ts";
export const MAIL_FROM = { email: `no-reply@${Brand.domain}`, name: Brand.name,} as const;
export const MailerBinding = (binding: SendEmail) => Layer.succeed( Mailer, Mailer.of({ send: (mail) => Effect.tryPromise({ catch: () => new MailFailed(), try: () => binding.send({ from: MAIL_FROM, subject: mail.subject, text: mail.text, to: mail.to, }), }).pipe(Effect.asVoid), }) );