Browse Source

put together api

takeru0001 5 years ago
parent
commit
af5ad4cb39
1 changed files with 3 additions and 16 deletions
  1. 3 16
      src/server/routes/apiv3/bookmarks.js

+ 3 - 16
src/server/routes/apiv3/bookmarks.js

@@ -96,9 +96,11 @@ module.exports = (crowi) => {
    */
   router.get('/', accessTokenParser, loginRequired, async(req, res) => {
     const { pageId } = req.query;
+    const bookmark = {};
 
     try {
-      const bookmark = await Bookmark.findByPageIdAndUserId(pageId, req.user);
+      bookmark.page = await Bookmark.findByPageIdAndUserId(pageId, req.user);
+      bookmark.sumOfBookmarks = await Bookmark.countByPageId(pageId);
       return res.apiv3({ bookmark });
     }
     catch (err) {
@@ -179,20 +181,5 @@ module.exports = (crowi) => {
    *                  $ref: '#/components/schemas/Bookmark'
    */
 
-
-  router.get('/count-bookmarks', accessTokenParser, loginRequired, validator.countBookmarks, apiV3FormValidator, async(req, res) => {
-    const { pageId } = req.query;
-
-    try {
-      const sumOfBookmarks = await Bookmark.countByPageId(pageId);
-      return res.apiv3({ sumOfBookmarks });
-    }
-    catch (err) {
-      logger.error('get-bookmarks-list-failed', err);
-      return res.apiv3Err(err, 500);
-    }
-  });
-
-
   return router;
 };