Remove email and move fully to app router
This commit is contained in:
parent
76a526cd1a
commit
b23761c106
6 changed files with 15 additions and 82 deletions
|
@ -37,7 +37,6 @@
|
||||||
"react-dom": "18.2.0",
|
"react-dom": "18.2.0",
|
||||||
"react-email": "^1.9.4",
|
"react-email": "^1.9.4",
|
||||||
"react-icons": "^4.10.1",
|
"react-icons": "^4.10.1",
|
||||||
"resend": "^1.0.0",
|
|
||||||
"sharp": "^0.32.5",
|
"sharp": "^0.32.5",
|
||||||
"superjson": "1.13.1",
|
"superjson": "1.13.1",
|
||||||
"zod": "^3.22.2"
|
"zod": "^3.22.2"
|
||||||
|
|
|
@ -1,51 +0,0 @@
|
||||||
import {
|
|
||||||
Body,
|
|
||||||
Container,
|
|
||||||
Head,
|
|
||||||
Heading,
|
|
||||||
Hr,
|
|
||||||
Html,
|
|
||||||
Img,
|
|
||||||
Preview,
|
|
||||||
Section,
|
|
||||||
Text,
|
|
||||||
} from "@react-email/components";
|
|
||||||
import * as React from "react";
|
|
||||||
|
|
||||||
interface WelcomeTemplateProps {
|
|
||||||
name: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
const baseUrl = process.env.VERCEL_URL
|
|
||||||
? `https://${process.env.VERCEL_URL}`
|
|
||||||
: "http://localhost:3000";
|
|
||||||
|
|
||||||
export const Welcome = ({ name }: WelcomeTemplateProps) => (
|
|
||||||
<Html>
|
|
||||||
<Head />
|
|
||||||
<Preview>🎉 Welcome to Sprint Padawan! 🎉</Preview>
|
|
||||||
<Body>
|
|
||||||
<Container>
|
|
||||||
<Section>
|
|
||||||
<Img
|
|
||||||
src={`${baseUrl}/logo.webp`}
|
|
||||||
width="40"
|
|
||||||
height="37"
|
|
||||||
alt={`Sprint Padawan Logo`}
|
|
||||||
/>
|
|
||||||
</Section>
|
|
||||||
<Heading>
|
|
||||||
🎉 Welcome to Sprint Padawan, <strong>{name}</strong>! 🎉
|
|
||||||
</Heading>
|
|
||||||
<Text>Hello {name},</Text>
|
|
||||||
<Text>Thank you for signing up for Sprint Padawan!</Text>
|
|
||||||
<Text>
|
|
||||||
If at any point you encounter issues, please let me know at
|
|
||||||
support@sprintpadawan.dev.
|
|
||||||
</Text>
|
|
||||||
<Hr />
|
|
||||||
<Text>— Atridad Lahiji</Text>
|
|
||||||
</Container>
|
|
||||||
</Body>
|
|
||||||
</Html>
|
|
||||||
);
|
|
|
@ -1,13 +1,13 @@
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
export const config = {
|
export const runtime = "edge";
|
||||||
runtime: "edge",
|
export const preferredRegion = ["pdx1"];
|
||||||
regions: ["pdx1"],
|
|
||||||
};
|
|
||||||
|
|
||||||
export default function handler() {
|
function handler() {
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ message: "Private Pong!" },
|
{ message: "Private Pong!" },
|
||||||
{ status: 200, statusText: "SUCCESS" }
|
{ status: 200, statusText: "SUCCESS" }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export { handler as GET };
|
|
@ -1,13 +1,13 @@
|
||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
export const config = {
|
export const runtime = "edge";
|
||||||
runtime: "edge",
|
export const preferredRegion = ["pdx1"];
|
||||||
regions: ["pdx1"],
|
|
||||||
};
|
|
||||||
|
|
||||||
export default function handler() {
|
function handler() {
|
||||||
return NextResponse.json(
|
return NextResponse.json(
|
||||||
{ message: "Public Pong!" },
|
{ message: "Public Pong!" },
|
||||||
{ status: 200, statusText: "SUCCESS" }
|
{ status: 200, statusText: "SUCCESS" }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export { handler as GET };
|
|
@ -9,12 +9,10 @@ import {
|
||||||
WebhookEvents,
|
WebhookEvents,
|
||||||
} from "~/utils/types";
|
} from "~/utils/types";
|
||||||
|
|
||||||
export const config = {
|
export const runtime = "edge";
|
||||||
runtime: "edge",
|
export const preferredRegion = ["pdx1"];
|
||||||
regions: ["pdx1"],
|
|
||||||
};
|
|
||||||
|
|
||||||
export default async function handler(req: NextRequest) {
|
async function handler(req: NextRequest) {
|
||||||
try {
|
try {
|
||||||
const eventBody = (await req.json()) as WebhookEventBody;
|
const eventBody = (await req.json()) as WebhookEventBody;
|
||||||
const { data, type } = WebhookEventBodySchema.parse(eventBody);
|
const { data, type } = WebhookEventBodySchema.parse(eventBody);
|
||||||
|
@ -61,3 +59,5 @@ export default async function handler(req: NextRequest) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export { handler as POST };
|
|
@ -2,10 +2,6 @@ import { eq } from "drizzle-orm";
|
||||||
import { db } from "./db";
|
import { db } from "./db";
|
||||||
import { rooms } from "./schema";
|
import { rooms } from "./schema";
|
||||||
import { env } from "~/env.mjs";
|
import { env } from "~/env.mjs";
|
||||||
import { Welcome } from "~/app/_components/templates/Welcome";
|
|
||||||
import { Resend } from "resend";
|
|
||||||
|
|
||||||
const resend = new Resend(env.RESEND_API_KEY);
|
|
||||||
|
|
||||||
export const onUserDeletedHandler = async (userId: string) => {
|
export const onUserDeletedHandler = async (userId: string) => {
|
||||||
try {
|
try {
|
||||||
|
@ -41,16 +37,5 @@ export const onUserCreatedHandler = async (
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
if (userUpdateResponse.ok) {
|
|
||||||
userEmails.forEach((userEmail) => {
|
|
||||||
void resend.sendEmail({
|
|
||||||
from: "no-reply@sprintpadawan.dev",
|
|
||||||
to: userEmail,
|
|
||||||
subject: "🎉 Welcome to Sprint Padawan! 🎉",
|
|
||||||
react: Welcome({ name: userName ? userEmail : userEmail }),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return userUpdateResponse.ok;
|
return userUpdateResponse.ok;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue