From 8b35abe25fdd99f5d19e5ea99967a211b1fdba00 Mon Sep 17 00:00:00 2001 From: Michael Drury Date: Wed, 4 Nov 2020 14:05:11 +0000 Subject: [PATCH] Updating screens API to be prefixed with /api/screens --- packages/builder/src/builderStore/store/index.js | 4 ++-- packages/server/src/api/routes/screen.js | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/builder/src/builderStore/store/index.js b/packages/builder/src/builderStore/store/index.js index 9f1ce9e555..44806e09c3 100644 --- a/packages/builder/src/builderStore/store/index.js +++ b/packages/builder/src/builderStore/store/index.js @@ -142,7 +142,7 @@ const saveScreen = store => async screen => { let savePromise await api - .post(`/api/${currentPage._id}/screens`, screen) + .post(`/api/screens/${currentPage._id}`, screen) .then(() => { if (currentPageScreens.includes(screen)) return @@ -262,7 +262,7 @@ const deleteScreens = store => (screens, pageName = null) => { state.pages[pageName]._screens = state.pages[pageName]._screens.filter( scr => scr.name !== screen.name ) - api.delete(`/_builder/api/pages/${pageName}/screens/${screen.name}`) + api.delete(`/api/screens/${screen._id}/${screen._rev}`) } return state }) diff --git a/packages/server/src/api/routes/screen.js b/packages/server/src/api/routes/screen.js index e36a09d610..407bbd1a94 100644 --- a/packages/server/src/api/routes/screen.js +++ b/packages/server/src/api/routes/screen.js @@ -27,13 +27,17 @@ function generateSaveValidation() { router .get("/api/screens", authorized(BUILDER), controller.fetch) - .get("/api/:pageId/screens", authorized(BUILDER), controller.find) + .get("/api/screens/:pageId", authorized(BUILDER), controller.find) .post( - "/api/:pageId/screens", + "/api/screens/:pageId", authorized(BUILDER), generateSaveValidation(), controller.save ) - .delete("/api/:screenId/:revId", authorized(BUILDER), controller.destroy) + .delete( + "/api/screens/:screenId/:revId", + authorized(BUILDER), + controller.destroy + ) module.exports = router