New project structure
Beta of extract.js for extracting english locale
This commit is contained in:
parent
e18d2b2f84
commit
2edbd67205
247 changed files with 6405 additions and 4237 deletions
25
server/routes/rest/editors.js
Normal file
25
server/routes/rest/editors.js
Normal file
|
@ -0,0 +1,25 @@
|
|||
'use strict';
|
||||
|
||||
const passport = require('../../lib/passport');
|
||||
|
||||
const bluebird = require('bluebird');
|
||||
const premailerApi = require('premailer-api');
|
||||
const premailerPrepareAsync = bluebird.promisify(premailerApi.prepare);
|
||||
|
||||
const router = require('../../lib/router-async').create();
|
||||
|
||||
router.postAsync('/html-to-text', passport.loggedIn, passport.csrfProtection, async (req, res) => {
|
||||
if (!req.body.html) {
|
||||
return res.json({text: ''}); // Premailer crashes very hard when html is empty
|
||||
}
|
||||
|
||||
const email = await premailerPrepareAsync({
|
||||
html: req.body.html,
|
||||
fetchHTML: false
|
||||
});
|
||||
|
||||
res.json({text: email.text.replace(/%5B/g, '[').replace(/%5D/g, ']')});
|
||||
|
||||
});
|
||||
|
||||
module.exports = router;
|
Loading…
Add table
Add a link
Reference in a new issue