const path = require("path"); require("dotenv").config({ path: path.resolve(process.cwd(), `.env.${process.env.NODE_ENV || "development"}`) }); const logger = require("../utils/logger"); //const inlineCssTool = require("inline-css"); const juice = require("juice"); exports.inlinecss = async (req, res) => { //Perform request validation logger.log("email-inline-css", "DEBUG", req.user.email, null, null); const { html, url } = req.body; try { const inlinedHtml = juice(html, { applyAttributesTableElements: false, preserveMediaQueries: false, applyWidthAttributes: false }); res.send(inlinedHtml); } catch (error) { logger.log("email-inline-css-error", "ERROR", req.user.email, null, { error }); res.send(error.message); } // inlineCssTool(html, { url: url }) // .then((inlinedHtml) => { // res.send(inlinedHtml); // }) // .catch((error) => { // logger.log("email-inline-css-error", "ERROR", req.user.email, null, { // error // }); // }); };