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:
parent
1fbe0746a4
commit
a5d6cf04cf
9 changed files with 169 additions and 48 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue