Skip to content

Commit

Permalink
fix: resend sdk version
Browse files Browse the repository at this point in the history
  • Loading branch information
scopsy committed Jan 14, 2024
1 parent 0adb2c5 commit 03701e1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 70 deletions.
75 changes: 11 additions & 64 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion providers/resend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"dependencies": {
"@novu/stateless": "^0.22.0",
"resend": "^0.17.2"
"resend": "^2.1.0"
},
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.1",
Expand Down
7 changes: 5 additions & 2 deletions providers/resend/src/lib/resend.provider.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { ResendEmailProvider } from './resend.provider';
import { Resend } from 'resend';

import { ResendEmailProvider } from './resend.provider';
const mockConfig = {
apiKey: 'this-api-key-from-resend',
from: '[email protected]',
};

(global as any).Headers = () => {};

const mockNovuMessage = {
from: '[email protected]',
to: ['[email protected]'],
Expand Down Expand Up @@ -48,7 +51,7 @@ test('should trigger resend email with From Name', async () => {

const provider = new ResendEmailProvider(mockConfigWithSenderName);
const spy = jest
.spyOn(Resend.prototype, 'sendEmail')
.spyOn((provider as any).resendClient.emails, 'send')
.mockImplementation(async () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return {} as any;
Expand Down
6 changes: 3 additions & 3 deletions providers/resend/src/lib/resend.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class ResendEmailProvider implements IEmailProvider {
const senderName = options.senderName || this.config?.senderName;
const fromAddress = options.from || this.config.from;

const response: any = await this.resendClient.sendEmail({
const response = await this.resendClient.emails.send({
from: senderName ? `${senderName} <${fromAddress}>` : fromAddress,
to: options.to,
subject: options.subject,
Expand All @@ -44,7 +44,7 @@ export class ResendEmailProvider implements IEmailProvider {
});

return {
id: response.id,
id: response.data?.id,
date: new Date().toISOString(),
};
}
Expand All @@ -53,7 +53,7 @@ export class ResendEmailProvider implements IEmailProvider {
options: IEmailOptions
): Promise<ICheckIntegrationResponse> {
try {
await this.resendClient.sendEmail({
await this.resendClient.emails.send({
from: options.from || this.config.from,
to: options.to,
subject: options.subject,
Expand Down

0 comments on commit 03701e1

Please sign in to comment.