mirror of
https://github.com/pawelmalak/flame.git
synced 2025-07-21 20:39:36 +02:00
Changed config api. Split config controllers into separate files. Split bookmarks controllers into separate files
This commit is contained in:
parent
76e50624e7
commit
cfb471e578
23 changed files with 579 additions and 602 deletions
27
controllers/bookmarks/createBookmark.js
Normal file
27
controllers/bookmarks/createBookmark.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
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 (req.file) {
|
||||
_body.icon = req.file.filename;
|
||||
}
|
||||
|
||||
bookmark = await Bookmark.create(_body);
|
||||
|
||||
res.status(201).json({
|
||||
success: true,
|
||||
data: bookmark,
|
||||
});
|
||||
});
|
||||
|
||||
module.exports = createBookmark;
|
Loading…
Add table
Add a link
Reference in a new issue