mirror of
https://github.com/pawelmalak/flame.git
synced 2024-12-29 21:42:23 +03:00
32 lines
637 B
JavaScript
32 lines
637 B
JavaScript
const asyncWrapper = require('../../middleware/asyncWrapper');
|
|
const Bookmark = require('../../models/Bookmark');
|
|
|
|
// @desc Create new bookmark
|
|
// @route POST /api/bookmarks
|
|
// @access Public
|
|
const createBookmark = asyncWrapper(async (req, res, next) => {
|
|
let bookmark;
|
|
|
|
let body = {
|
|
...req.body,
|
|
categoryId: parseInt(req.body.categoryId),
|
|
};
|
|
|
|
if (body.icon) {
|
|
body.icon = body.icon.trim();
|
|
}
|
|
|
|
if (req.file) {
|
|
body.icon = req.file.filename;
|
|
}
|
|
|
|
bookmark = await Bookmark.create(body);
|
|
|
|
res.status(201).json({
|
|
success: true,
|
|
data: bookmark,
|
|
});
|
|
});
|
|
|
|
module.exports = createBookmark;
|