Removed obsolete dir
Numeric conversions for all ids coming in as route req params. Infrastructure for proper error message when dependencies prevent entity deletion.
This commit is contained in:
parent
2b57396a5d
commit
0a08088893
636 changed files with 291 additions and 73346 deletions
|
@ -4,16 +4,17 @@ const passport = require('../../lib/passport');
|
|||
const sendConfigurations = require('../../models/send-configurations');
|
||||
|
||||
const router = require('../../lib/router-async').create();
|
||||
const {castToInteger} = require('../../lib/helpers');
|
||||
|
||||
|
||||
router.getAsync('/send-configurations-private/:sendConfigurationId', passport.loggedIn, async (req, res) => {
|
||||
const sendConfiguration = await sendConfigurations.getById(req.context, req.params.sendConfigurationId, true, true);
|
||||
const sendConfiguration = await sendConfigurations.getById(req.context, castToInteger(req.params.sendConfigurationId), true, true);
|
||||
sendConfiguration.hash = sendConfigurations.hash(sendConfiguration);
|
||||
return res.json(sendConfiguration);
|
||||
});
|
||||
|
||||
router.getAsync('/send-configurations-public/:sendConfigurationId', passport.loggedIn, async (req, res) => {
|
||||
const sendConfiguration = await sendConfigurations.getById(req.context, req.params.sendConfigurationId, true, false);
|
||||
const sendConfiguration = await sendConfigurations.getById(req.context, castToInteger(req.params.sendConfigurationId), true, false);
|
||||
sendConfiguration.hash = sendConfigurations.hash(sendConfiguration);
|
||||
return res.json(sendConfiguration);
|
||||
});
|
||||
|
@ -24,14 +25,14 @@ router.postAsync('/send-configurations', passport.loggedIn, passport.csrfProtect
|
|||
|
||||
router.putAsync('/send-configurations/:sendConfigurationId', passport.loggedIn, passport.csrfProtection, async (req, res) => {
|
||||
const sendConfiguration = req.body;
|
||||
sendConfiguration.id = parseInt(req.params.sendConfigurationId);
|
||||
sendConfiguration.id = castToInteger(req.params.sendConfigurationId);
|
||||
|
||||
await sendConfigurations.updateWithConsistencyCheck(req.context, sendConfiguration);
|
||||
return res.json();
|
||||
});
|
||||
|
||||
router.deleteAsync('/send-configurations/:sendConfigurationId', passport.loggedIn, passport.csrfProtection, async (req, res) => {
|
||||
await sendConfigurations.remove(req.context, req.params.sendConfigurationId);
|
||||
await sendConfigurations.remove(req.context, castToInteger(req.params.sendConfigurationId));
|
||||
return res.json();
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue