in functions/sendOrderConfirmation/index.js [25:50]
async function prepareOrderConfirmation(type, context) {
var emailTemplateDocument = await firestore
.collection(`emails`)
.doc(type)
.get();
var subject;
var from;
var pugSource;
if (!emailTemplateDocument.exists) {
throw new Error(`Invalid template type.`);
} else {
var emailTemplate = emailTemplateDocument.data();
subject = emailTemplate.subject;
from = emailTemplate.from;
pugSource = emailTemplate.template;
}
var compile = pug.compile(pugSource);
return {
to: context.email,
from: from,
subject: subject,
html: compile(context)
};
}