Add email via Resend

This commit is contained in:
NeilClack
2026-07-06 21:01:41 -05:00
parent 96eafafbf6
commit a42c32f014
16 changed files with 210 additions and 116 deletions
+25
View File
@@ -0,0 +1,25 @@
/** src/routes/send/+server.ts
* AUTHOR: Neil Clack
* EMAIL: nclack@radiantwavetech.com
* DATE: 07/06/2027
*
* An example endpoint, temporarily enabled, to describe
* how to send an email with the Resend API and our custom
* sendMail function.
*
*/
import { json } from '@sveltejs/kit';
import { sendMail } from '$lib/server/resend';
import type { RequestHandler } from './$types';
export const POST: RequestHandler = async ({ request }) => {
const { to, subject, templateId, data } = await request.json();
try {
const result = await sendMail({ to, subject, templateId, data });
return json(result);
} catch (e) {
return json({ error: (e as Error).message }, { status: 400 });
}
};