From 743f0eedd2e09a4d1576347c6c32db8fa449faaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dario=20Mi=C3=B1ones?= Date: Thu, 31 Oct 2019 12:49:38 -0300 Subject: [PATCH 1/4] Changing Readme --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 622e8e7..bb9a621 100644 --- a/README.md +++ b/README.md @@ -68,13 +68,15 @@ This extension for Keystone is intended to create a REST API very easy. Also is // Make sure keystone is initialized and started before // calling createRest + keystone.init(config); - keystone.start(); // Add routes with Keystone keystoneRestApi.createRest(keystone, { - apiRoot: '/api/v1/' + apiRoot: '/api/' }); + + keystone.start(); // Create Documentation and write it to a file fs.writeFileSync('api.md', keystoneRestApi.apiDocs(), 'UTF-8'); From eb0ef550f02406bc9c567da6b2f988ad56912752 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dario=20Mi=C3=B1ones?= Date: Thu, 31 Oct 2019 12:59:17 -0300 Subject: [PATCH 2/4] Fixing route set --- index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 563e4de..5e2efa7 100644 --- a/index.js +++ b/index.js @@ -808,8 +808,10 @@ function KeystoneRest() { // Get and register the models _registerRestModels(keystone); - _.each(self.routes, function (route) { - keystone.app[route.method](route.route, route.middleware, route.handler); + keystone.set('routes', app => { + _.each(self.routes, function (route) { + app[route.method](route.route, route.middleware, route.handler); + }); }); }; From e50c40a67d09c54833964b052a9680a40b368d69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dario=20Mi=C3=B1ones?= Date: Thu, 31 Oct 2019 14:47:29 -0300 Subject: [PATCH 3/4] Mantaining currentRoutes --- index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/index.js b/index.js index 5e2efa7..b92de07 100644 --- a/index.js +++ b/index.js @@ -808,7 +808,9 @@ function KeystoneRest() { // Get and register the models _registerRestModels(keystone); + const setCurrentRoutes = keystone.get('routes') keystone.set('routes', app => { + setCurrentRoutes(app) _.each(self.routes, function (route) { app[route.method](route.route, route.middleware, route.handler); }); From 3751ffd133b05eb3e06c8e2a486b93578f2ca4bc Mon Sep 17 00:00:00 2001 From: Jorge Shirai Date: Wed, 27 Nov 2019 14:53:30 -0300 Subject: [PATCH 4/4] Parse limit and skip as numbers. --- index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index b92de07..1c9222a 100644 --- a/index.js +++ b/index.js @@ -369,9 +369,10 @@ function KeystoneRest() { if (err) { return _sendError(err, req, res, next); } - - var query = Model.find(criteria).skip(req.query.skip) - .limit(req.query.limit) + var limit = req.query.limit ? Number.parseInt(req.query.limit) : undefined; + var skip = req.query.skip ? Number.parseInt(req.query.skip) : undefined; + var query = Model.find(criteria).skip(skip) + .limit(limit) .sort(req.query.sort) .select(querySelect || selected);