forked from captableinc/captable
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauth-verification-email.ts
More file actions
33 lines (29 loc) · 916 Bytes
/
Copy pathauth-verification-email.ts
File metadata and controls
33 lines (29 loc) · 916 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import AccountVerificationEmail from "@/emails/AccountVerificationEmail";
import { env } from "@/env";
import { sendMail } from "@/server/mailer";
import { render } from "@react-email/components";
import { z } from "zod";
import { defineJob, defineWorker, defineWorkerConfig } from "../lib/queue";
const config = defineWorkerConfig({
name: "email.auth-verify",
schema: z.object({
email: z.string(),
token: z.string(),
}),
});
export const authVerificationEmailJob = defineJob(config);
export const authVerificationEmailWorker = defineWorker(config, async (job) => {
const { email, token } = job.data;
const baseUrl = env.NEXT_PUBLIC_BASE_URL;
const confirmLink = `${baseUrl}/verify-email/${token}`;
const html = await render(
AccountVerificationEmail({
verifyLink: confirmLink,
}),
);
await sendMail({
to: email,
subject: "Confirm your email",
html,
});
});