From 4245d429b98dd4b5fecc596c3c0c76846a6dfd7c Mon Sep 17 00:00:00 2001 From: Michael Shanks Date: Wed, 26 Feb 2020 15:58:55 +0000 Subject: [PATCH] server - listRecords routes should use a wildcard param --- packages/server/middleware/routers.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/packages/server/middleware/routers.js b/packages/server/middleware/routers.js index b7cd5c53a2..08169463ab 100644 --- a/packages/server/middleware/routers.js +++ b/packages/server/middleware/routers.js @@ -302,13 +302,15 @@ module.exports = (config, app) => { ctx.body = await ctx.instance.authApi.getAccessLevels() ctx.response.status = StatusCodes.OK }) - .get("/:appname/api/listRecords/:indexkey", async ctx => { - ctx.body = await ctx.instance.indexApi.listItems(ctx.params.indexkey) + .get("/:appname/api/listRecords/*", async ctx => { + const indexkey = getRecordKey(ctx.params.appname, ctx.request.path) + ctx.body = await ctx.instance.indexApi.listItems(indexkey) ctx.response.status = StatusCodes.OK }) - .post("/:appname/api/listRecords/:indexkey", async ctx => { + .post("/:appname/api/listRecords/*", async ctx => { + const indexkey = getRecordKey(ctx.params.appname, ctx.request.path) ctx.body = await ctx.instance.indexApi.listItems( - ctx.request.body.indexKey, + indexkey, { rangeStartParams: ctx.request.body.rangeStartParams, rangeEndParams: ctx.request.body.rangeEndParams, @@ -317,9 +319,10 @@ module.exports = (config, app) => { ) ctx.response.status = StatusCodes.OK }) - .post("/:appname/api/aggregates/:indexkey", async ctx => { + .post("/:appname/api/aggregates/*", async ctx => { + const indexkey = getRecordKey(ctx.params.appname, ctx.request.path) ctx.body = await ctx.instance.indexApi.aggregates( - ctx.request.body.indexKey, + indexkey, { rangeStartParams: ctx.request.body.rangeStartParams, rangeEndParams: ctx.request.body.rangeEndParams, @@ -394,6 +397,8 @@ module.exports = (config, app) => { .replace(`/${appname}/api/files/`, "") .replace(`/${appname}/api/lookup_field/`, "") .replace(`/${appname}/api/record/`, "") + .replace(`/${appname}/api/listRecords/`, "") + .replace(`/${appname}/api/aggregates/`, "") return router }