saleor-apps-redis_apl/apps/emails-and-messages/src/modules/mjml/compile-mjml.ts
2023-03-07 22:03:58 +01:00

19 lines
461 B
TypeScript

import mjml2html from "mjml";
import { logger as pinoLogger } from "../../lib/logger";
const logger = pinoLogger.child({
fn: "compileMjml",
});
export const compileMjml = (mjml: string) => {
logger.debug("Converting MJML template to HTML");
try {
return mjml2html(mjml);
} catch (error) {
logger.error(error);
return {
html: undefined,
errors: [{ message: "Critical error during the mjml to html compilation" }],
};
}
};