Factory that returns an EmailProvider instance based on config, used to abstract provider selection.
// Source: https://github.com/mnfst/llm-gateway | License: MIT | Copyright 2026 MNFST, Inc
// Provided via justclaw.it.com; keep this notice with the code.
import { EmailProvider, EmailProviderConfig } from './email-provider.interface';
import { MailgunProvider } from './mailgun.provider';
import { SendGridProvider } from './sendgrid.provider';
import { ResendProvider } from './resend.provider';
export function createProvider(config: EmailProviderConfig): EmailProvider {
switch (config.provider) {
case 'mailgun':
return new MailgunProvider(config);
case 'sendgrid':
return new SendGridProvider(config);
case 'resend':
return new ResendProvider(config);
default:
throw new Error(`Unknown email provider: ${config.provider}`);
}
}
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key