♻️ Improve email abstraction (#861)

This commit is contained in:
Luke Vella 2023-09-15 14:21:35 +01:00 committed by GitHub
parent 9e453da1dd
commit 93cc5b9b4d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 749 additions and 152 deletions

View file

@ -1,10 +1,10 @@
import { prisma } from "@rallly/database";
import { sendEmail } from "@rallly/emails";
import { absoluteUrl } from "@rallly/utils";
import { TRPCError } from "@trpc/server";
import { z } from "zod";
import { createToken, decryptToken } from "../../session";
import { emailClient } from "../../utils/email-client";
import { generateOtp } from "../../utils/nanoid";
import { publicProcedure, router } from "../trpc";
import { LoginTokenPayload, RegistrationTokenPayload } from "../types";
@ -107,7 +107,7 @@ export const auth = router({
code,
});
await sendEmail("RegisterEmail", {
await emailClient.sendTemplate("RegisterEmail", {
to: input.email,
subject: `${input.name}, please verify your email address`,
props: {
@ -193,7 +193,7 @@ export const auth = router({
code,
});
await sendEmail("LoginEmail", {
await emailClient.sendTemplate("LoginEmail", {
to: input.email,
subject: `${code} is your 6-digit code`,
props: {