Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add resend api #201

Merged
merged 5 commits into from
Oct 28, 2024
Merged

Add resend api #201

merged 5 commits into from
Oct 28, 2024

Conversation

CahidArda
Copy link
Contributor

@CahidArda CahidArda commented Oct 21, 2024

adds resend api used like this:

await client.publishJSON({
  api: {
    name: "email",
    provider: resend({ token: process.env.RESEND_TOKEN! }),
  },
  body: {
    from: "Acme <[email protected]>",
    to: ["[email protected]"],
    subject: "hello world",
    html: "<p>it works!</p>",
  },
});

body is not typesafe. Out llm api isn't typesafe too. It's not very simple to make it typesafe currently.

We can go ahead with this version and make it typesafe later

Copy link

linear bot commented Oct 21, 2024

@enesakar
Copy link
Contributor

cc? bcc?

@CahidArda
Copy link
Contributor Author

since it's not typesafe, it will work with all parameters in https://resend.com/docs/api-reference/emails/send-email

@fahreddinozcan
Copy link
Collaborator

I feel like we can still handle batch operation without passing the batch param to the resend client. Like inferring from the object count in the body maybe?

        await client.publishJSON({
          api: {
            name: "email",
            provider: resend({ token: resendToken }),
          },
          body: [
            {
              from: "Acme <[email protected]>",
              to: ["[email protected]"],
              subject: "hello world",
              html: "<h1>it works!</h1>",
            },
            {
              from: "Acme <[email protected]>",
              to: ["[email protected]"],
              subject: "world hello",
              html: "<p>it works!</p>",
            },
          ],
        });
      },

@CahidArda
Copy link
Contributor Author

That sounds nice but I would prefer to avoid putting in logic we would have to maintain.

A similar optimization could have been made in qstash-js publishJSON vs batch, or it could have been done by resend itself (having a single API for single & batch email).

@CahidArda CahidArda merged commit b0bf9f3 into main Oct 28, 2024
6 checks passed
@CahidArda CahidArda deleted the DX-1310-add-resend-api branch October 28, 2024 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants