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,19 +4,20 @@ const passport = require('../../lib/passport');
|
|||
const files = require('../../models/files');
|
||||
const router = require('../../lib/router-async').create();
|
||||
const fileHelpers = require('../../lib/file-helpers');
|
||||
const {castToInteger} = require('../../lib/helpers');
|
||||
|
||||
router.postAsync('/files-table/:type/:subType/:entityId', passport.loggedIn, async (req, res) => {
|
||||
return res.json(await files.listDTAjax(req.context, req.params.type, req.params.subType, req.params.entityId, req.body));
|
||||
return res.json(await files.listDTAjax(req.context, req.params.type, req.params.subType, castToInteger(req.params.entityId), req.body));
|
||||
});
|
||||
|
||||
router.getAsync('/files/:type/:subType/:fileId', passport.loggedIn, async (req, res) => {
|
||||
const file = await files.getFileById(req.context, req.params.type, req.params.subType, req.params.fileId);
|
||||
const file = await files.getFileById(req.context, req.params.type, req.params.subType, castToInteger(req.params.fileId));
|
||||
res.type(file.mimetype);
|
||||
return res.download(file.path, file.name);
|
||||
});
|
||||
|
||||
router.deleteAsync('/files/:type/:subType/:fileId', passport.loggedIn, async (req, res) => {
|
||||
await files.removeFile(req.context, req.params.type, req.params.subType, req.params.fileId);
|
||||
await files.removeFile(req.context, req.params.type, req.params.subType, castToInteger(req.params.fileId));
|
||||
return res.json();
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue