import type { MailAdapter } from '@platform-modules/mail';
import { makeResendAdapter } from '@platform-modules/mail/resend';

export type MailEnv = {
  MAIL_PROVIDER?: string;
  RESEND_API_KEY?: string;
  MAIL_FROM?: string;
};

export function buildMailAdapter(env: MailEnv): MailAdapter | null {
  if (env.MAIL_PROVIDER === 'resend' && env.RESEND_API_KEY) {
    return makeResendAdapter({ apiKey: env.RESEND_API_KEY });
  }
  return null;
}
