Add email via Resend
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import type { RequestHandler } from "./$types";
|
||||
|
||||
export const POST: RequestHandler = async () => {
|
||||
// Request validation (400)
|
||||
// 1. Validate and extract information
|
||||
|
||||
// Business rule validation (409)
|
||||
// 2. Check for existing entries
|
||||
|
||||
// Resource creation (500 on unexpected failures)
|
||||
// 3. Create new entries
|
||||
// 5. Create license key
|
||||
|
||||
// External operations (502/503/504 or 500, depending on your API)
|
||||
// 4. Send profile setup email
|
||||
// 6. Send license key email
|
||||
|
||||
// Success (200/201)
|
||||
// 7. Send response
|
||||
return new Response(JSON.stringify({ "msg": "success" }))
|
||||
}
|
||||
@@ -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 });
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user