updated code for new package
This commit is contained in:
1 parent
f02a6b31fa
commit
fdb59866b3
2 files changed
+3
-3
No files matched your search
+1
-1
@@ -85,7 +85,7 @@ const startApp = async () => {
|
|||||||
|
|
||||||
app.use("/api/v1/mail", async (req, res) => {
|
app.use("/api/v1/mail", async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const id = await req.emailSerivce.buildAndSendEmail(
|
const id = await req.emailService.buildAndSendEmail(
|
||||||
"welcomeEmailTemplate",
|
"welcomeEmailTemplate",
|
||||||
{
|
{
|
||||||
name: "Alex",
|
name: "Alex",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ const fs = require("fs");
|
|||||||
const path = require("path");
|
const path = require("path");
|
||||||
const nodemailer = require("nodemailer");
|
const nodemailer = require("nodemailer");
|
||||||
const { compile } = require("handlebars");
|
const { compile } = require("handlebars");
|
||||||
const { mjml2html } = require("mjml");
|
const mjml2html = require("mjml");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an email service that can load templates, build, and send emails.
|
* Represents an email service that can load templates, build, and send emails.
|
||||||
@@ -68,7 +68,7 @@ class EmailService {
|
|||||||
buildAndSendEmail = async (template, context, to, subject) => {
|
buildAndSendEmail = async (template, context, to, subject) => {
|
||||||
const buildHtml = (template, context) => {
|
const buildHtml = (template, context) => {
|
||||||
const mjml = this.templateLookup[template](context);
|
const mjml = this.templateLookup[template](context);
|
||||||
const html = mjml2html(mjml);
|
const html = mjml2html(mjml).html;
|
||||||
return html;
|
return html;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user