Files
alla-allaos-fullstack/src/features/foundation/notifications/server/provider-factory.ts

22 lines
618 B
TypeScript

import 'server-only';
import { EmailNotificationProvider } from './email-provider';
import type { NotificationChannel, NotificationProvider } from '../types';
export function getNotificationProvider(
channel: NotificationChannel,
providerKey?: string,
): NotificationProvider {
if (channel === 'email') {
const provider = new EmailNotificationProvider();
if (providerKey && provider.key !== providerKey) {
throw new Error(`Unsupported email provider: ${providerKey}`);
}
return provider;
}
throw new Error(`Notification provider for channel ${channel} is not implemented yet.`);
}