Browse Source

add query options

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

+ 5 - 3
src/server/routes/apiv3/pages.js

@@ -7,8 +7,6 @@ const express = require('express');
 
 
 const router = express.Router();
 const router = express.Router();
 
 
-const PAGE_ITEMS = 5;
-
 
 
 /**
 /**
  * @swagger
  * @swagger
@@ -88,8 +86,12 @@ module.exports = (crowi) => {
 
 
   router.get('/list', accessTokenParser, loginRequired, async(req, res) => {
   router.get('/list', accessTokenParser, loginRequired, async(req, res) => {
     const { path } = req.query;
     const { path } = req.query;
+    const limit = +req.query.limit || 50;
+    const offset = +req.query.offset || 0;
+    const queryOptions = { offset, limit };
+
     try {
     try {
-      const result = await Page.findListWithDescendants(path, req.user, { limit:, offset});
+      const result = await Page.findListWithDescendants(path, req.user, queryOptions);
 
 
       return res.apiv3(result);
       return res.apiv3(result);
     }
     }