@vynelix/vynemit-adapter-sendgrid
v1.0.0
Published
SendGrid transport adapter for Vynemit
Maintainers
Readme
@vynelix/vynemit-adapter-sendgrid
SendGrid transport adapter for Vynemit.
Installation
npm install @vynelix/vynemit-adapter-sendgridUsage
import { NotificationCenter } from '@vynelix/vynemit-core';
import { SendGridProvider } from '@vynelix/vynemit-adapter-sendgrid';
const sendgrid = new SendGridProvider({
apiKey: process.env.SENDGRID_API_KEY,
fromEmail: '[email protected]',
debug: true // Optional: enables detailed logging
});
const nc = new NotificationCenter({
transports: [sendgrid],
// ... other config
});Dynamic Templates
This adapter supports SendGrid Dynamic Templates. Pass the templateId and templateData in the notification data:
await nc.send({
userId: 'user-123',
title: 'Welcome!', // Fallback subject
body: '...', // Fallback body
data: {
email: '[email protected]',
templateId: 'd-xxxxxxxxxxxxxxxx',
templateData: {
firstName: 'John',
inviteUrl: 'https://example.com/invite'
}
}
});Health Check
The adapter includes a non-invasive health check that verifies API key validity without sending actual emails.
const isHealthy = await sendgrid.healthCheck();