From c78b14a68a491b0e5585719c42a5a4f8f8704c1a Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Tue, 7 Apr 2020 17:41:57 +0100 Subject: [PATCH] better client id endpoint --- packages/server/middleware/controllers/application.js | 3 ++- packages/server/middleware/routes/neo/application.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/server/middleware/controllers/application.js b/packages/server/middleware/controllers/application.js index 8f80e0db1e..f6e3c82df7 100644 --- a/packages/server/middleware/controllers/application.js +++ b/packages/server/middleware/controllers/application.js @@ -2,7 +2,8 @@ const couchdb = require("../../db"); const controller = { create: async ctx => { - ctx.body = await couchdb.db.create(ctx.request.body.appName); + const clientDatabase = couchdb.db.use(ctx.params.clientId); + ctx.body = await clientDatabase.create(ctx.request.body.appname); } } diff --git a/packages/server/middleware/routes/neo/application.js b/packages/server/middleware/routes/neo/application.js index 6670362142..4c600dc54e 100644 --- a/packages/server/middleware/routes/neo/application.js +++ b/packages/server/middleware/routes/neo/application.js @@ -3,6 +3,6 @@ const controller = require("../../controllers/application"); const router = Router(); -router.post("/api/applications/:clientId", controller.create) +router.post("/api/:clientId/applications", controller.create) module.exports = router; \ No newline at end of file