Skip to content
This repository has been archived by the owner on Jul 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #6 from detrash/feat/support-email
Browse files Browse the repository at this point in the history
feat: add resend and create support route
  • Loading branch information
yurimutti authored Jul 11, 2024
2 parents b673722 + 5f11b71 commit 267bf75
Show file tree
Hide file tree
Showing 4 changed files with 255 additions and 33 deletions.
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ AUTH0_BASE_URL=
AUTH0_ISSUER_DOMAIN=
AUTH0_CLIENT_SECRET=
AUTH0_CLIENT_ID=


# Emails
RESEND_API_KEY=
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"postgres": "^3.4.4",
"react": "^18",
"react-dom": "^18",
"resend": "^3.4.0",
"zod": "^3.23.8"
},
"devDependencies": {
Expand Down
24 changes: 24 additions & 0 deletions src/app/api/send/support/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Resend } from 'resend';

const resend = new Resend(process.env.RESEND_API_KEY);

export async function POST(req: Request) {
const { email } = await req.json();

try {
const { data, error } = await resend.emails.send({
from: '[email protected]',
to: ['[email protected]', '[email protected]'],
subject: 'I want a personalized support',
html: `<strong>Email:</strong> ${email}`,
});

if (error) {
return Response.json({ error }, { status: 500 });
}

return Response.json(data);
} catch (error) {
return Response.json({ error }, { status: 500 });
}
}
Loading

0 comments on commit 267bf75

Please sign in to comment.