resend 0.17.0 → 0.17.2
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/build/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "resend",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.2",
|
|
4
4
|
"description": "Node.js library for the Resend API",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/src/index.d.ts",
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
"homepage": "https://github.com/resend-inc/resend-node#readme",
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@react-email/render": "0.0.7",
|
|
31
|
-
"axios": "1.4.0"
|
|
31
|
+
"axios": "1.4.0",
|
|
32
|
+
"type-fest": "3.13.0"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
34
35
|
"@types/jest": "29.5.3",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { PostOptions } from '../../common/interfaces';
|
|
4
|
+
import { RequireAtLeastOne } from 'type-fest';
|
|
4
5
|
interface CreateEmailBaseOptions {
|
|
5
6
|
attachments?: Attachment[];
|
|
6
7
|
bcc?: string | string[];
|
|
@@ -8,20 +9,14 @@ interface CreateEmailBaseOptions {
|
|
|
8
9
|
from: string;
|
|
9
10
|
headers?: Record<string, string>;
|
|
10
11
|
react?: React.ReactElement | React.ReactNode | null;
|
|
12
|
+
html?: string;
|
|
13
|
+
text?: string;
|
|
11
14
|
reply_to?: string | string[];
|
|
12
15
|
subject: string;
|
|
13
16
|
tags?: Tag[];
|
|
14
17
|
to: string | string[];
|
|
15
18
|
}
|
|
16
|
-
|
|
17
|
-
html: string;
|
|
18
|
-
text?: string;
|
|
19
|
-
}
|
|
20
|
-
interface CreateEmailWithTextOptions extends CreateEmailBaseOptions {
|
|
21
|
-
html?: string;
|
|
22
|
-
text: string;
|
|
23
|
-
}
|
|
24
|
-
export type CreateEmailOptions = CreateEmailWithHtmlOptions | CreateEmailWithTextOptions;
|
|
19
|
+
export type CreateEmailOptions = RequireAtLeastOne<CreateEmailBaseOptions, 'react' | 'html' | 'text'>;
|
|
25
20
|
export interface CreateEmailRequestOptions extends PostOptions {
|
|
26
21
|
}
|
|
27
22
|
export interface CreateEmailResponse {
|
package/build/src/resend.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ import { Emails } from './emails/emails';
|
|
|
6
6
|
import { CreateEmailOptions, CreateEmailResponse } from './emails/interfaces';
|
|
7
7
|
export declare class Resend {
|
|
8
8
|
readonly key?: string | undefined;
|
|
9
|
-
readonly baseUrl: string;
|
|
10
9
|
private readonly headers;
|
|
11
10
|
private readonly request;
|
|
12
11
|
readonly apiKeys: ApiKeys;
|
package/build/src/resend.js
CHANGED
|
@@ -19,6 +19,8 @@ const package_json_1 = require("../package.json");
|
|
|
19
19
|
const api_keys_1 = require("./api-keys/api-keys");
|
|
20
20
|
const domains_1 = require("./domains/domains");
|
|
21
21
|
const emails_1 = require("./emails/emails");
|
|
22
|
+
const baseUrl = process.env.RESEND_BASE_URL || 'https://api.resend.com';
|
|
23
|
+
const userAgent = process.env.RESEND_USER_AGENT || `resend-node:${package_json_1.version}`;
|
|
22
24
|
class Resend {
|
|
23
25
|
constructor(key) {
|
|
24
26
|
this.key = key;
|
|
@@ -31,14 +33,13 @@ class Resend {
|
|
|
31
33
|
throw new Error('Missing API key. Pass it to the constructor `new Resend("re_123")`');
|
|
32
34
|
}
|
|
33
35
|
}
|
|
34
|
-
this.baseUrl = process.env.RESEND_BASE_URL || 'https://api.resend.com';
|
|
35
36
|
this.headers = {
|
|
36
37
|
Authorization: `Bearer ${this.key}`,
|
|
37
|
-
'User-Agent':
|
|
38
|
+
'User-Agent': userAgent,
|
|
38
39
|
'Content-Type': 'application/json',
|
|
39
40
|
};
|
|
40
41
|
this.request = axios_1.default.create({
|
|
41
|
-
baseURL:
|
|
42
|
+
baseURL: baseUrl,
|
|
42
43
|
headers: this.headers,
|
|
43
44
|
maxContentLength: Infinity,
|
|
44
45
|
maxBodyLength: Infinity,
|
|
@@ -114,7 +115,7 @@ class Resend {
|
|
|
114
115
|
sendEmail(data) {
|
|
115
116
|
return __awaiter(this, void 0, void 0, function* () {
|
|
116
117
|
try {
|
|
117
|
-
const path = `${
|
|
118
|
+
const path = `${baseUrl}/email`;
|
|
118
119
|
if (data.react) {
|
|
119
120
|
data.html = (0, render_1.render)(data.react);
|
|
120
121
|
delete data.react;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "resend",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.2",
|
|
4
4
|
"description": "Node.js library for the Resend API",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/src/index.d.ts",
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
"homepage": "https://github.com/resend-inc/resend-node#readme",
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@react-email/render": "0.0.7",
|
|
31
|
-
"axios": "1.4.0"
|
|
31
|
+
"axios": "1.4.0",
|
|
32
|
+
"type-fest": "3.13.0"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
34
35
|
"@types/jest": "29.5.3",
|