@cedarjs/mailer-handler-resend 7.0.0-canary.3231 → 7.0.0-canary.3234

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/README.md CHANGED
@@ -54,3 +54,21 @@ const resendClient = resendHandler.internal().client
54
54
 
55
55
  You should be able to use this newly configured handler like any other previous
56
56
  handler and it should require no changes to your mailer code.
57
+
58
+ ## Error Handling
59
+
60
+ `mailer.send()` rejects when Resend does not accept the email, for example
61
+ because of an invalid API key, an unverified sender domain, or a rate limit. The
62
+ error message contains Resend's error name and message, and the error response
63
+ from Resend is available as the `cause` of the thrown error.
64
+
65
+ ```typescript
66
+ try {
67
+ await mailer.send(/* ... */)
68
+ } catch (error) {
69
+ if (error instanceof Error) {
70
+ // For example: { name: 'rate_limit_exceeded', message: '...' }
71
+ console.error(error.cause)
72
+ }
73
+ }
74
+ ```
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,OAAO,KAAK,EACV,uBAAuB,EACvB,mBAAmB,EACnB,UAAU,EACX,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAE1D,MAAM,MAAM,wBAAwB,GAAG;IAIrC,IAAI,CAAC,EAAE;QACL,IAAI,EAAE,MAAM,CAAA;QACZ,KAAK,EAAE,MAAM,CAAA;KACd,EAAE,CAAA;CACJ,CAAA;AAED,UAAU,4BAA4B;IACpC,4CAA4C;IAC5C,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,UAAU,mCAAmC;IAC3C,MAAM,EAAE,MAAM,CAAA;CACf;AAOD,qBAAa,iBAAkB,SAAQ,mBAAmB;IACxD,OAAO,CAAC,MAAM,CAAQ;gBAEV,EAAE,MAAM,EAAE,EAAE,mCAAmC;IAC3D,qEAAqE;gBACzD,EAAE,QAAQ,EAAE,EAAE,4BAA4B;IAMhD,IAAI,CACR,OAAO,EAAE,mBAAmB,EAC5B,WAAW,EAAE,uBAAuB,EACpC,cAAc,CAAC,EAAE,wBAAwB,GACxC,OAAO,CAAC,UAAU,CAAC;IA+CtB,QAAQ;;;CAKT"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,OAAO,KAAK,EACV,uBAAuB,EACvB,mBAAmB,EACnB,UAAU,EACX,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAE1D,MAAM,MAAM,wBAAwB,GAAG;IAIrC,IAAI,CAAC,EAAE;QACL,IAAI,EAAE,MAAM,CAAA;QACZ,KAAK,EAAE,MAAM,CAAA;KACd,EAAE,CAAA;CACJ,CAAA;AAED,UAAU,4BAA4B;IACpC,4CAA4C;IAC5C,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,UAAU,mCAAmC;IAC3C,MAAM,EAAE,MAAM,CAAA;CACf;AAOD,qBAAa,iBAAkB,SAAQ,mBAAmB;IACxD,OAAO,CAAC,MAAM,CAAQ;gBAEV,EAAE,MAAM,EAAE,EAAE,mCAAmC;IAC3D,qEAAqE;gBACzD,EAAE,QAAQ,EAAE,EAAE,4BAA4B;IAMhD,IAAI,CACR,OAAO,EAAE,mBAAmB,EAC5B,WAAW,EAAE,uBAAuB,EACpC,cAAc,CAAC,EAAE,wBAAwB,GACxC,OAAO,CAAC,UAAU,CAAC;IA2DtB,QAAQ;;;CAKT"}
package/dist/index.js CHANGED
@@ -40,8 +40,14 @@ class ResendMailHandler extends AbstractMailHandler {
40
40
  // Resend specific options
41
41
  tags: handlerOptions?.tags ?? []
42
42
  });
43
+ if (result.error) {
44
+ throw new Error(
45
+ `Resend failed to send the email: ${result.error.name}: ` + result.error.message,
46
+ { cause: result.error }
47
+ );
48
+ }
43
49
  return {
44
- messageID: result.data?.id,
50
+ messageID: result.data.id,
45
51
  handlerInformation: result
46
52
  };
47
53
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/mailer-handler-resend",
3
- "version": "7.0.0-canary.3231",
3
+ "version": "7.0.0-canary.3234",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/cedarjs/cedar.git",
@@ -18,15 +18,18 @@
18
18
  "build:pack": "yarn pack -o cedarjs-mailer-handler-resend.tgz",
19
19
  "build:types": "tsc --build --verbose ./tsconfig.build.json",
20
20
  "build:watch": "nodemon --watch src --ext \"js,jsx,ts,tsx\" --ignore dist --exec \"yarn build\"",
21
- "prepublishOnly": "NODE_ENV=production yarn build"
21
+ "prepublishOnly": "NODE_ENV=production yarn build",
22
+ "test": "vitest run",
23
+ "test:watch": "vitest watch"
22
24
  },
23
25
  "dependencies": {
24
- "@cedarjs/mailer-core": "7.0.0-canary.3231",
26
+ "@cedarjs/mailer-core": "7.0.0-canary.3234",
25
27
  "resend": "4.8.0"
26
28
  },
27
29
  "devDependencies": {
28
- "@cedarjs/framework-tools": "7.0.0-canary.3231",
29
- "typescript": "5.9.3"
30
+ "@cedarjs/framework-tools": "7.0.0-canary.3234",
31
+ "typescript": "5.9.3",
32
+ "vitest": "4.1.11"
30
33
  },
31
34
  "publishConfig": {
32
35
  "access": "public"