Remove email and move fully to app router

This commit is contained in:
Atridad Lahiji 2023-08-28 00:31:47 -06:00
parent 76a526cd1a
commit b23761c106
No known key found for this signature in database
6 changed files with 15 additions and 82 deletions

View file

@ -37,7 +37,6 @@
"react-dom": "18.2.0",
"react-email": "^1.9.4",
"react-icons": "^4.10.1",
"resend": "^1.0.0",
"sharp": "^0.32.5",
"superjson": "1.13.1",
"zod": "^3.22.2"

View file

@ -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>
);

View file

@ -1,13 +1,13 @@
import { NextResponse } from "next/server";
export const config = {
runtime: "edge",
regions: ["pdx1"],
};
export const runtime = "edge";
export const preferredRegion = ["pdx1"];
export default function handler() {
function handler() {
return NextResponse.json(
{ message: "Private Pong!" },
{ status: 200, statusText: "SUCCESS" }
);
}
export { handler as GET };

View file

@ -1,13 +1,13 @@
import { NextResponse } from "next/server";
export const config = {
runtime: "edge",
regions: ["pdx1"],
};
export const runtime = "edge";
export const preferredRegion = ["pdx1"];
export default function handler() {
function handler() {
return NextResponse.json(
{ message: "Public Pong!" },
{ status: 200, statusText: "SUCCESS" }
);
}
export { handler as GET };

View file

@ -9,12 +9,10 @@ import {
WebhookEvents,
} from "~/utils/types";
export const config = {
runtime: "edge",
regions: ["pdx1"],
};
export const runtime = "edge";
export const preferredRegion = ["pdx1"];
export default async function handler(req: NextRequest) {
async function handler(req: NextRequest) {
try {
const eventBody = (await req.json()) as WebhookEventBody;
const { data, type } = WebhookEventBodySchema.parse(eventBody);
@ -61,3 +59,5 @@ export default async function handler(req: NextRequest) {
);
}
}
export { handler as POST };

View file

@ -2,10 +2,6 @@ import { eq } from "drizzle-orm";
import { db } from "./db";
import { rooms } from "./schema";
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) => {
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;
};