@ooneex/mailer 1.1.12 → 1.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -50,7 +50,7 @@ declare const MailerLayout: MailerLayoutComponentType;
50
50
  import { AppEnv } from "@ooneex/app-env";
51
51
  declare class ResendMailer implements IMailer {
52
52
  private readonly env;
53
- private apiKey;
53
+ private readonly client;
54
54
  private from?;
55
55
  constructor(env: AppEnv);
56
56
  send(config: {
package/dist/index.js CHANGED
@@ -13216,18 +13216,19 @@ var $renderToStaticMarkup = l.renderToStaticMarkup;
13216
13216
  import { Resend } from "resend";
13217
13217
  class ResendMailer {
13218
13218
  env;
13219
- apiKey;
13219
+ client;
13220
13220
  from;
13221
13221
  constructor(env) {
13222
13222
  this.env = env;
13223
- this.apiKey = this.env.RESEND_API_KEY;
13223
+ const apiKey = this.env.RESEND_API_KEY;
13224
13224
  this.from = {
13225
13225
  name: this.env.MAILER_SENDER_NAME || "",
13226
13226
  address: this.env.MAILER_SENDER_ADDRESS || ""
13227
13227
  };
13228
- if (!this.apiKey) {
13228
+ if (!apiKey) {
13229
13229
  throw new MailerException("Resend API key is required. Please set the RESEND_API_KEY environment variable.", "API_KEY_REQUIRED");
13230
13230
  }
13231
+ this.client = new Resend(apiKey);
13231
13232
  }
13232
13233
  async send(config) {
13233
13234
  const senderName = config.from?.name || this.from?.name || "";
@@ -13238,8 +13239,7 @@ class ResendMailer {
13238
13239
  if (!senderAddress) {
13239
13240
  throw new MailerException("Mailer sender address is required. Please provide a sender address either through the send options or set the MAILER_SENDER_ADDRESS environment variable.", "EMAIL_OPERATION_FAILED");
13240
13241
  }
13241
- const client = new Resend(this.apiKey);
13242
- await client.emails.send({
13242
+ await this.client.emails.send({
13243
13243
  to: config.to,
13244
13244
  from: `${senderName} <${senderAddress}>`,
13245
13245
  subject: `${config.subject}`,
@@ -13261,4 +13261,4 @@ export {
13261
13261
  MailerException
13262
13262
  };
13263
13263
 
13264
- //# debugId=B7E3D2851729689964756E2164756E21
13264
+ //# debugId=72C1200D335068C264756E2164756E21