codalware-auth
Version:
Complete authentication system with enterprise security, attack protection, team workspaces, waitlist, billing, UI components, 2FA, and account recovery - production-ready in 5 minutes. Enhanced CLI with verification, rollback, and App Router scaffolding.
14 lines (12 loc) • 578 B
text/typescript
import type { EmailProvider, MailArgs } from './types';
import * as sg from '@sendgrid/mail';
export function createSendGridProvider(opts: { apiKey?: string } = {}): EmailProvider {
const apiKey = opts.apiKey ?? process.env.SENDGRID_API_KEY;
if (!apiKey) throw new Error('SENDGRID_API_KEY required');
return {
async sendMail(args: MailArgs) {
(sg as any).setApiKey(apiKey);
await (sg as any).send({ to: args.to, from: process.env.EMAIL_FROM || 'no-reply@example.com', subject: args.subject, text: args.text, html: args.html });
},
};
}