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
44
server/routes/rest/templates.js
Normal file
44
server/routes/rest/templates.js
Normal file
|
@ -0,0 +1,44 @@
|
|||
'use strict';
|
||||
|
||||
const passport = require('../../lib/passport');
|
||||
const templates = require('../../models/templates');
|
||||
|
||||
const router = require('../../lib/router-async').create();
|
||||
const {castToInteger} = require('../../lib/helpers');
|
||||
const CampaignSender = require('../../lib/campaign-sender');
|
||||
|
||||
|
||||
router.getAsync('/templates/:templateId', passport.loggedIn, async (req, res) => {
|
||||
const template = await templates.getById(req.context, castToInteger(req.params.templateId));
|
||||
template.hash = templates.hash(template);
|
||||
return res.json(template);
|
||||
});
|
||||
|
||||
router.postAsync('/templates', passport.loggedIn, passport.csrfProtection, async (req, res) => {
|
||||
return res.json(await templates.create(req.context, req.body));
|
||||
});
|
||||
|
||||
router.putAsync('/templates/:templateId', passport.loggedIn, passport.csrfProtection, async (req, res) => {
|
||||
const template = req.body;
|
||||
template.id = castToInteger(req.params.templateId);
|
||||
|
||||
await templates.updateWithConsistencyCheck(req.context, template);
|
||||
return res.json();
|
||||
});
|
||||
|
||||
router.deleteAsync('/templates/:templateId', passport.loggedIn, passport.csrfProtection, async (req, res) => {
|
||||
await templates.remove(req.context, castToInteger(req.params.templateId));
|
||||
return res.json();
|
||||
});
|
||||
|
||||
router.postAsync('/templates-table', passport.loggedIn, async (req, res) => {
|
||||
return res.json(await templates.listDTAjax(req.context, req.body));
|
||||
});
|
||||
|
||||
router.postAsync('/template-test-send', passport.loggedIn, passport.csrfProtection, async (req, res) => {
|
||||
const data = req.body;
|
||||
const result = await CampaignSender.testSend(req.context, data.listCid, data.subscriptionCid, data.campaignId, data.sendConfigurationId, data.html, data.text);
|
||||
return res.json(result);
|
||||
});
|
||||
|
||||
module.exports = router;
|
Loading…
Add table
Add a link
Reference in a new issue