1
0
Fork 0
mirror of https://github.com/pawelmalak/flame.git synced 2025-07-19 03:29:37 +02:00

Custom icons for bookmarks

This commit is contained in:
unknown 2021-07-28 12:36:03 +02:00
parent 1fbe0746a4
commit a5d6cf04cf
9 changed files with 169 additions and 48 deletions

View file

@ -7,7 +7,18 @@ const { Sequelize } = require('sequelize');
// @route POST /api/bookmarks
// @access Public
exports.createBookmark = asyncWrapper(async (req, res, next) => {
const bookmark = await Bookmark.create(req.body);
let bookmark;
let _body = {
...req.body,
categoryId: parseInt(req.body.categoryId)
};
if (req.file) {
_body.icon = req.file.filename;
}
bookmark = await Bookmark.create(_body);
res.status(201).json({
success: true,
@ -59,7 +70,16 @@ exports.updateBookmark = asyncWrapper(async (req, res, next) => {
return next(new ErrorResponse(`Bookmark with id of ${req.params.id} was not found`, 404));
}
bookmark = await bookmark.update({ ...req.body });
let _body = {
...req.body,
categoryId: parseInt(req.body.categoryId)
};
if (req.file) {
_body.icon = req.file.filename;
}
bookmark = await bookmark.update(_body);
res.status(200).json({
success: true,