2.3.0 Dev Tools (#180)

* 2.3.0 - Added new Dev Tools app
This commit is contained in:
Giancarlo Buomprisco
2025-02-21 13:29:42 +07:00
committed by GitHub
parent 59dfc0ad91
commit c185bcfa11
36 changed files with 3747 additions and 67 deletions

View File

@@ -0,0 +1,57 @@
import {
renderAccountDeleteEmail,
renderInviteEmail,
} from '@kit/email-templates';
export async function loadEmailTemplate(id: string) {
if (id === 'account-delete-email') {
return renderAccountDeleteEmail({
productName: 'Makerkit',
userDisplayName: 'Giancarlo',
});
}
if (id === 'invite-email') {
return renderInviteEmail({
teamName: 'Makerkit',
teamLogo:
'',
inviter: 'Giancarlo',
invitedUserEmail: 'test@makerkit.dev',
link: 'https://makerkit.dev',
productName: 'Makerkit',
});
}
if (id === 'magic-link-email') {
return loadFromFileSystem('magic-link');
}
if (id === 'reset-password-email') {
return loadFromFileSystem('reset-password');
}
if (id === 'change-email-address-email') {
return loadFromFileSystem('change-email-address');
}
if (id === 'confirm-email') {
return loadFromFileSystem('confirm-email');
}
throw new Error(`Email template not found: ${id}`);
}
async function loadFromFileSystem(fileName: string) {
const { readFileSync } = await import('node:fs');
const { join } = await import('node:path');
const filePath = join(
process.cwd(),
`../web/supabase/templates/${fileName}.html`,
);
return {
html: readFileSync(filePath, 'utf8'),
};
}

View File

@@ -0,0 +1,11 @@
import { z } from 'zod';
export const EmailTesterFormSchema = z.object({
username: z.string().min(1),
password: z.string().min(1),
sender: z.string().min(1),
to: z.string().email(),
host: z.string().min(1),
port: z.number().min(1),
tls: z.boolean(),
});

View File

@@ -0,0 +1,38 @@
'use server';
import { loadEmailTemplate } from '@/app/emails/lib/email-loader';
export async function sendEmailAction(params: {
template: string;
settings: {
username: string;
password: string;
sender: string;
host: string;
to: string;
port: number;
tls: boolean;
};
}) {
const { settings } = params;
const { createTransport } = await import('nodemailer');
const transporter = createTransport({
host: settings.host,
port: settings.port,
secure: settings.tls,
auth: {
user: settings.username,
pass: settings.password,
},
});
const { html } = await loadEmailTemplate(params.template);
return transporter.sendMail({
html,
from: settings.sender,
to: settings.to,
subject: 'Test Email',
});
}