mirror of
https://github.com/harivansh-afk/Saas-Teamspace.git
synced 2026-04-17 01:04:43 +00:00
initial commit
This commit is contained in:
commit
ef9ccf22d3
133 changed files with 20802 additions and 0 deletions
47
app/api/emails/route.ts
Normal file
47
app/api/emails/route.ts
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
import { Resend } from "resend"
|
||||
import RepoEmail from "@/components/email/email";
|
||||
import { render } from "@react-email/render"
|
||||
import { NextResponse } from 'next/server';
|
||||
|
||||
const resend = new Resend(process.env.RESEND_API_KEY);
|
||||
|
||||
export async function POST(request: Request) {
|
||||
try {
|
||||
const { email } = await request.json();
|
||||
|
||||
const { data, error } = await resend.emails.send({
|
||||
from: "Nizzy <noreply@nizzystarter.com>",
|
||||
to: [email],
|
||||
subject: "Nizzy Starter Kit",
|
||||
html: render(RepoEmail()),
|
||||
});
|
||||
|
||||
if (error) {
|
||||
return new NextResponse(JSON.stringify(error), {
|
||||
status: 500,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
await resend.contacts.create({
|
||||
email: email,
|
||||
audienceId: process.env.RESEND_AUDIENCE as string
|
||||
});
|
||||
|
||||
return new NextResponse(JSON.stringify({ message: "Email sent successfully" }), {
|
||||
status: 200,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
});
|
||||
} catch (error:any) {
|
||||
return new NextResponse(JSON.stringify({ error: error.message }), {
|
||||
status: 500,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue