I have a Nextjs app that utilizes both React-Email, Resend & Firebase Cloud Functions. The directory structure looks like this:
I want to send an email to a user whenever a doc is created in “emailVerification” collection, here’s what the cloud function looks like:
import * as logger from "firebase-functions/logger";
import {onDocumentCreated} from "firebase-functions/v2/firestore";
import { Resend } from 'resend'
import EmailVerificationTemplate from '../../react-email/emails/EmailVerification'
import { render } from '@react-email/components';
const resend = new Resend(RESEND_API_KEY);
export const sendEmailVerification = onDocumentCreated("/emailVerifications/{id}", async (event) => {
// Grab the current value of what was written to Firestore.
const data = event?.data?.data();
// Access the parameter `{documentId}` with `event.params`
logger.log("Requesting email verification for uid", event.params.id, data);
const emailHtml = render(EmailVerificationTemplate({
validationCode: data?.code.toString()
}));
await resend.emails.send({
from: '[email protected]',
to: data?.email,
subject: 'Your Halbert Verification Code',
html: emailHtml
});
});
However, I’m getting this error when I try to deploy this function using: firebase deploy –only functions:
How do I solve for these errors?