mirror of
https://github.com/pawelmalak/flame.git
synced 2026-03-06 20:43:13 +08:00
Changed config api. Split config controllers into separate files. Split bookmarks controllers into separate files
This commit is contained in:
28
controllers/bookmarks/getSingleBookmark.js
Normal file
28
controllers/bookmarks/getSingleBookmark.js
Normal file
@@ -0,0 +1,28 @@
|
||||
const asyncWrapper = require('../../middleware/asyncWrapper');
|
||||
const ErrorResponse = require('../../utils/ErrorResponse');
|
||||
const Bookmark = require('../../models/Bookmark');
|
||||
|
||||
// @desc Get single bookmark
|
||||
// @route GET /api/bookmarks/:id
|
||||
// @access Public
|
||||
const getSingleBookmark = asyncWrapper(async (req, res, next) => {
|
||||
const bookmark = await Bookmark.findOne({
|
||||
where: { id: req.params.id },
|
||||
});
|
||||
|
||||
if (!bookmark) {
|
||||
return next(
|
||||
new ErrorResponse(
|
||||
`Bookmark with the id of ${req.params.id} was not found`,
|
||||
404
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
res.status(200).json({
|
||||
success: true,
|
||||
data: bookmark,
|
||||
});
|
||||
});
|
||||
|
||||
module.exports = getSingleBookmark;
|
||||
Reference in New Issue
Block a user