Fixes typescript errors

This commit is contained in:
James Ritchie
2025-09-07 15:38:02 +01:00
parent d3a7fcca7e
commit 6677844eec
2 changed files with 14 additions and 16 deletions
@@ -1,37 +1,36 @@
import { render } from "@react-email/render";
import { EmailError, MailMessage, MailTransport, PlainTextMailMessage } from "./index";
import nodemailer from "nodemailer"
import * as awsSes from "@aws-sdk/client-ses"
import nodemailer from "nodemailer";
import * as awsSes from "@aws-sdk/client-ses";
export type AwsSesMailTransportOptions = {
type: 'aws-ses',
}
type: "aws-ses";
};
export class AwsSesMailTransport implements MailTransport {
#client: nodemailer.Transporter;
constructor(options: AwsSesMailTransportOptions) {
const ses = new awsSes.SESClient()
const ses = new awsSes.SESClient();
this.#client = nodemailer.createTransport({
SES: {
aws: awsSes,
ses
}
})
ses,
},
});
}
async send({to, from, replyTo, subject, react}: MailMessage): Promise<void> {
async send({ to, from, replyTo, subject, react }: MailMessage): Promise<void> {
try {
await this.#client.sendMail({
from: from,
to,
replyTo: replyTo,
subject,
html: render(react),
html: await render(react),
});
}
catch (error) {
} catch (error) {
if (error instanceof Error) {
console.error(
`Failed to send email to ${to}, ${subject}. Error ${error.name}: ${error.message}`
@@ -43,7 +42,7 @@ export class AwsSesMailTransport implements MailTransport {
}
}
async sendPlainText({to, from, replyTo, subject, text}: PlainTextMailMessage): Promise<void> {
async sendPlainText({ to, from, replyTo, subject, text }: PlainTextMailMessage): Promise<void> {
try {
await this.#client.sendMail({
from: from,
@@ -52,8 +51,7 @@ export class AwsSesMailTransport implements MailTransport {
subject,
text: text,
});
}
catch (error) {
} catch (error) {
if (error instanceof Error) {
console.error(
`Failed to send email to ${to}, ${subject}. Error ${error.name}: ${error.message}`
@@ -29,7 +29,7 @@ export class SmtpMailTransport implements MailTransport {
to,
replyTo: replyTo,
subject,
html: render(react),
html: await render(react),
});
} catch (error) {
if (error instanceof Error) {