@absolutejs/ 发送转发
后端备份 EmailAdapter 页:1
@absolutejs/发送。 。 。 .
文档 : 绝对js.com/文档/发送#适应器
安装
bun add @absolutejs/dispatch @absolutejs/dispatch-resend resend
使用量
import { Resend } from "resend";
import { createDispatcher } from "@absolutejs/dispatch";
import { createResendAdapter } from "@absolutejs/dispatch-resend";
const resend = new Resend(process.env.RESEND_KEY!);
const dispatcher = createDispatcher({
email: createResendAdapter({
client: resend,
defaultFrom: "[email protected]",
}),
});
const result = await dispatcher.email({
to: "[email protected]",
subject: "Welcome to Acme",
text: "Click here to verify: ...",
// String metadata becomes Resend tags by default:
metadata: { campaign: "welcome-v2", priority: "high" },
});
console.log(result.id); // Resend's message id
API 密码
createResendAdapter({
client, // Required — your `new Resend(apiKey)`
defaultFrom?, // Required if your messages don't set `from`
tagsFromMetadata?, // Customize metadata → Resend tags mapping
})
tagsFromMetadata
默认情况下适配器地图 字符串值 输入
message.metadata 转到 Resend 标签。 非字符串值(数字,
布尔, 对象) 被过滤出 — 需要重新发送 string 页:1
两者 name 财务报告和审定财务报表 value。 。 。 .
覆盖自定义 :
createResendAdapter({
client: resend,
tagsFromMetadata: (metadata) => [
// Always include the tenant
...(typeof metadata.tenant === "string"
? [{ name: "tenant", value: metadata.tenant }]
: []),
// Drop debug-only entries
],
});
映射错误
重新发送 { data, error } 响应形状变为:
error集 − 适配器抛出(@absolutejs/dispatch记录 例外规定dispatch.email.send间距,起伏failed计数器, 发送dispatch.email.failed审计活动).data.id现 ——DispatchResult.id= 重传消息 id.data.id缺少 +DispatchResult.id实值undefined, (中文(简体) ),result.provider还是'resend'。 。 。 .
许可证
Apache 2.0 (英语)B级基底相接于
绝对JS许可证政策——骑行 @absolutejs/dispatch (BSL 等级)
(a)和 resend (麻省理工学院).
套件还出口 resendEffectAdapterDescriptor 财务报告和审定财务报表
createResendEffectAdapterDriver() 页:1 @absolutejs/execution驱动程序
只有在执行时才接受已解决的证书,要求准确无误
重新发送 API 目的地和 email.send 效果,并推进持久效果
(原始内容存档于2018-10-21). idepotency key to Resend. 东道国保留对秘密储存的所有权并提供
窄处 clientForKey 在最后供应商边界的工厂.
持久效果网络记录证据
效果驱动程序添加一个 abs_effect 包含持久效果的再发送标签
ID 并宣布其完整的 Webhook 设置: 回调模板, 标准
Webhooks 头条,支持出行事件, 确切的秘密别名,
最后的验证-事件健康信号, 和签名-事件替换旋转.
主机可以传递精确的原始请求
机身,标准Webhooks头,项目租户身份, 和该项目的准确性
RESEND_WEBHOOK_SECRET 改为 verifyResendEffectWebhook()它使用 Resend 的 SDK
在返回正常状态之前进行核查 EffectEvidenceRecord; 接收者,
发件人、对象、信头和原始有效载荷从未归还储存.
描述符使用 webhook-query: 已签名的 webhooks 仍然为主, 而
createResendEffectQueryDriver() 只有在
执行保留了原调用返回的确切的Resend电子邮件ID.
执行驱动程序摘录了未保留
供应商的回应。 查询倒数验证取回的电子邮件ID及其
abs_effect 标记,然后返回正态证据。 如果一个模糊的网络
调用未返回 ID, 运行时间在解析 API 之前跳过此倒计时
键,并继续等待签名的 webhook 或操作员证据;它从未
重放发送.
全部支援出入境 email.* 博客事件证实 email.send
效果被Resend所接受,所以正常化的效果结果是
confirmed_succeeded。在 eventType (计:
实例 email.delivered, (中文(简体) ), email.bounced,或 email.failed) 并且绝不能是
与成功的收件箱发送相混淆。 入境 email.received联系人,
域名、 和无效签名的事件被拒绝.
Webhook 签名机密是主机入侵证书,而不是提供者发送
证书。 将一个存放在精确的项目秘密外号下
RESEND_WEBHOOK_SECRET; 不将其放置在适配器安装或解析器中
在电子邮件发送时.