mirror of
https://github.com/pawelmalak/flame.git
synced 2025-07-25 05:49:36 +02:00
Pushed version 1.6.7
This commit is contained in:
parent
4252457871
commit
6a6f1750b1
7 changed files with 217 additions and 162 deletions
|
@ -11,7 +11,7 @@ exports.createBookmark = asyncWrapper(async (req, res, next) => {
|
|||
|
||||
let _body = {
|
||||
...req.body,
|
||||
categoryId: parseInt(req.body.categoryId)
|
||||
categoryId: parseInt(req.body.categoryId),
|
||||
};
|
||||
|
||||
if (req.file) {
|
||||
|
@ -22,57 +22,67 @@ exports.createBookmark = asyncWrapper(async (req, res, next) => {
|
|||
|
||||
res.status(201).json({
|
||||
success: true,
|
||||
data: bookmark
|
||||
})
|
||||
})
|
||||
data: bookmark,
|
||||
});
|
||||
});
|
||||
|
||||
// @desc Get all bookmarks
|
||||
// @route GET /api/bookmarks
|
||||
// @access Public
|
||||
exports.getBookmarks = asyncWrapper(async (req, res, next) => {
|
||||
const bookmarks = await Bookmark.findAll({
|
||||
order: [[ Sequelize.fn('lower', Sequelize.col('name')), 'ASC' ]]
|
||||
order: [[Sequelize.fn('lower', Sequelize.col('name')), 'ASC']],
|
||||
});
|
||||
|
||||
res.status(200).json({
|
||||
success: true,
|
||||
data: bookmarks
|
||||
})
|
||||
})
|
||||
data: bookmarks,
|
||||
});
|
||||
});
|
||||
|
||||
// @desc Get single bookmark
|
||||
// @route GET /api/bookmarks/:id
|
||||
// @access Public
|
||||
exports.getBookmark = asyncWrapper(async (req, res, next) => {
|
||||
const bookmark = await Bookmark.findOne({
|
||||
where: { id: req.params.id }
|
||||
where: { id: req.params.id },
|
||||
});
|
||||
|
||||
if (!bookmark) {
|
||||
return next(new ErrorResponse(`Bookmark with id of ${req.params.id} was not found`, 404));
|
||||
return next(
|
||||
new ErrorResponse(
|
||||
`Bookmark with id of ${req.params.id} was not found`,
|
||||
404
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
res.status(200).json({
|
||||
success: true,
|
||||
data: bookmark
|
||||
})
|
||||
})
|
||||
data: bookmark,
|
||||
});
|
||||
});
|
||||
|
||||
// @desc Update bookmark
|
||||
// @route PUT /api/bookmarks/:id
|
||||
// @access Public
|
||||
exports.updateBookmark = asyncWrapper(async (req, res, next) => {
|
||||
let bookmark = await Bookmark.findOne({
|
||||
where: { id: req.params.id }
|
||||
where: { id: req.params.id },
|
||||
});
|
||||
|
||||
if (!bookmark) {
|
||||
return next(new ErrorResponse(`Bookmark with id of ${req.params.id} was not found`, 404));
|
||||
return next(
|
||||
new ErrorResponse(
|
||||
`Bookmark with id of ${req.params.id} was not found`,
|
||||
404
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
let _body = {
|
||||
...req.body,
|
||||
categoryId: parseInt(req.body.categoryId)
|
||||
categoryId: parseInt(req.body.categoryId),
|
||||
};
|
||||
|
||||
if (req.file) {
|
||||
|
@ -83,20 +93,20 @@ exports.updateBookmark = asyncWrapper(async (req, res, next) => {
|
|||
|
||||
res.status(200).json({
|
||||
success: true,
|
||||
data: bookmark
|
||||
})
|
||||
})
|
||||
data: bookmark,
|
||||
});
|
||||
});
|
||||
|
||||
// @desc Delete bookmark
|
||||
// @route DELETE /api/bookmarks/:id
|
||||
// @access Public
|
||||
exports.deleteBookmark = asyncWrapper(async (req, res, next) => {
|
||||
await Bookmark.destroy({
|
||||
where: { id: req.params.id }
|
||||
where: { id: req.params.id },
|
||||
});
|
||||
|
||||
res.status(200).json({
|
||||
success: true,
|
||||
data: {}
|
||||
})
|
||||
})
|
||||
data: {},
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue