Fixes typescript errors
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user