@absolutejs/dispatch-resend
v0.0.1
Published
Resend-backed EmailAdapter for @absolutejs/dispatch. Takes your Resend client; emits standard DispatchResult with the Resend message id.
Downloads
162
Maintainers
Readme
@absolutejs/dispatch-resend
Resend-backed EmailAdapter for
@absolutejs/dispatch.
Install
bun add @absolutejs/dispatch @absolutejs/dispatch-resend resendUsage
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 idAPI
createResendAdapter({
client, // Required — your `new Resend(apiKey)`
defaultFrom?, // Required if your messages don't set `from`
tagsFromMetadata?, // Customize metadata → Resend tags mapping
})tagsFromMetadata
By default the adapter maps every string-valued entry in
message.metadata to a Resend tag. Non-string values (numbers,
booleans, objects) are filtered out — Resend requires string for
both name and value.
Override to customize:
createResendAdapter({
client: resend,
tagsFromMetadata: (metadata) => [
// Always include the tenant
...(typeof metadata.tenant === 'string'
? [{ name: 'tenant', value: metadata.tenant }]
: []),
// Drop debug-only entries
],
});Error mapping
Resend's { data, error } response shape becomes:
errorset → adapter throws (@absolutejs/dispatchrecords the exception on thedispatch.email.sendspan, bumpsfailedcounter, emitsdispatch.email.failedaudit event).data.idpresent →DispatchResult.id= the Resend message id.data.idmissing →DispatchResult.idisundefined,result.providerstill'resend'.
License
Apache 2.0. Tier B substrate-adjacent under the
AbsoluteJS licensing policy — rides @absolutejs/dispatch (BSL Tier
A) and resend (MIT).
