All files / lib/email client.ts

100% Statements 12/12
100% Branches 6/6
100% Functions 1/1
100% Lines 12/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 301x               1x   1x 6x 6x       1x   1x   1x 1x         1x 4x 4x  
/**
 * Resend Email Client
 *
 * Server-side only - handles transactional emails
 */
 
import { Resend } from 'resend';
 
const EMAIL_CONFIGURED = !!process.env.RESEND_API_KEY;
 
if (!EMAIL_CONFIGURED) {
  console.warn('RESEND_API_KEY not configured. Email features will be disabled.');
}
 
// Only create the Resend instance if API key is configured
// This avoids build errors when API key is not set
const resendInstance = EMAIL_CONFIGURED ? new Resend(process.env.RESEND_API_KEY) : null;
 
export const resend = resendInstance as Resend;
 
export const EMAIL_FROM = process.env.EMAIL_FROM || 'ProofID <noreply@proofid.in>';
export const SUPPORT_EMAIL = process.env.SUPPORT_EMAIL || 'support@proofid.in';
 
/**
 * Check if email service is configured
 */
export function isEmailConfigured(): boolean {
  return EMAIL_CONFIGURED;
}