From e0dcc7648c308a55256cc7c8525860465de6613b Mon Sep 17 00:00:00 2001 From: Rory Powell Date: Fri, 21 Jan 2022 17:31:18 +0000 Subject: [PATCH] Remove server -> worker request to retrieve apps, remove hosting endpoints and store --- packages/builder/src/builderStore/index.js | 2 - .../src/builderStore/store/frontend.js | 2 - .../builder/src/builderStore/store/hosting.js | 34 --------- .../deploy/DeploymentHistory.svelte | 4 +- .../components/start/CreateAppModal.svelte | 12 ++- .../components/start/UpdateAppModal.svelte | 8 +- .../builder/src/helpers/validation/yup/app.js | 21 ++--- .../server/src/api/controllers/application.js | 76 ++++++++++++------- .../server/src/api/controllers/hosting.js | 22 ------ .../src/api/controllers/static/index.js | 12 ++- packages/server/src/api/routes/hosting.js | 13 ---- packages/server/src/api/routes/index.js | 2 - .../src/api/routes/tests/application.spec.js | 4 +- .../src/api/routes/tests/hosting.spec.js | 36 --------- .../src/tests/utilities/TestConfiguration.js | 4 +- .../server/src/utilities/workerRequests.js | 23 ------ packages/worker/src/api/controllers/app.js | 30 -------- packages/worker/src/api/routes/app.js | 8 -- packages/worker/src/api/routes/index.js | 2 - 19 files changed, 80 insertions(+), 235 deletions(-) delete mode 100644 packages/builder/src/builderStore/store/hosting.js delete mode 100644 packages/server/src/api/controllers/hosting.js delete mode 100644 packages/server/src/api/routes/hosting.js delete mode 100644 packages/server/src/api/routes/tests/hosting.spec.js delete mode 100644 packages/worker/src/api/controllers/app.js delete mode 100644 packages/worker/src/api/routes/app.js diff --git a/packages/builder/src/builderStore/index.js b/packages/builder/src/builderStore/index.js index 23704556ad..5181e756c6 100644 --- a/packages/builder/src/builderStore/index.js +++ b/packages/builder/src/builderStore/index.js @@ -1,6 +1,5 @@ import { getFrontendStore } from "./store/frontend" import { getAutomationStore } from "./store/automation" -import { getHostingStore } from "./store/hosting" import { getThemeStore } from "./store/theme" import { derived, writable } from "svelte/store" import { FrontendTypes, LAYOUT_NAMES } from "../constants" @@ -9,7 +8,6 @@ import { findComponent } from "./componentUtils" export const store = getFrontendStore() export const automationStore = getAutomationStore() export const themeStore = getThemeStore() -export const hostingStore = getHostingStore() export const currentAsset = derived(store, $store => { const type = $store.currentFrontEndType diff --git a/packages/builder/src/builderStore/store/frontend.js b/packages/builder/src/builderStore/store/frontend.js index fdfe450edf..0d740e08e0 100644 --- a/packages/builder/src/builderStore/store/frontend.js +++ b/packages/builder/src/builderStore/store/frontend.js @@ -2,7 +2,6 @@ import { get, writable } from "svelte/store" import { cloneDeep } from "lodash/fp" import { allScreens, - hostingStore, currentAsset, mainLayout, selectedComponent, @@ -100,7 +99,6 @@ export const getFrontendStore = () => { version: application.version, revertableVersion: application.revertableVersion, })) - await hostingStore.actions.fetch() // Initialise backend stores const [_integrations] = await Promise.all([ diff --git a/packages/builder/src/builderStore/store/hosting.js b/packages/builder/src/builderStore/store/hosting.js deleted file mode 100644 index fb174c2663..0000000000 --- a/packages/builder/src/builderStore/store/hosting.js +++ /dev/null @@ -1,34 +0,0 @@ -import { writable } from "svelte/store" -import api, { get } from "../api" - -const INITIAL_HOSTING_UI_STATE = { - appUrl: "", - deployedApps: {}, - deployedAppNames: [], - deployedAppUrls: [], -} - -export const getHostingStore = () => { - const store = writable({ ...INITIAL_HOSTING_UI_STATE }) - store.actions = { - fetch: async () => { - const response = await api.get("/api/hosting/urls") - const urls = await response.json() - store.update(state => { - state.appUrl = urls.app - return state - }) - }, - fetchDeployedApps: async () => { - let deployments = await (await get("/api/hosting/apps")).json() - store.update(state => { - state.deployedApps = deployments - state.deployedAppNames = Object.values(deployments).map(app => app.name) - state.deployedAppUrls = Object.values(deployments).map(app => app.url) - return state - }) - return deployments - }, - } - return store -} diff --git a/packages/builder/src/components/deploy/DeploymentHistory.svelte b/packages/builder/src/components/deploy/DeploymentHistory.svelte index f6bbcef4d4..36c2433c27 100644 --- a/packages/builder/src/components/deploy/DeploymentHistory.svelte +++ b/packages/builder/src/components/deploy/DeploymentHistory.svelte @@ -6,7 +6,7 @@ import api from "builderStore/api" import { notifications } from "@budibase/bbui" import CreateWebhookDeploymentModal from "./CreateWebhookDeploymentModal.svelte" - import { store, hostingStore } from "builderStore" + import { store } from "builderStore" const DeploymentStatus = { SUCCESS: "SUCCESS", @@ -37,7 +37,7 @@ let poll let deployments = [] let urlComponent = $store.url || `/${appId}` - let deploymentUrl = `${$hostingStore.appUrl}${urlComponent}` + let deploymentUrl = `${urlComponent}` const formatDate = (date, format) => Intl.DateTimeFormat("en-GB", DATE_OPTIONS[format]).format(date) diff --git a/packages/builder/src/components/start/CreateAppModal.svelte b/packages/builder/src/components/start/CreateAppModal.svelte index dccf8017aa..3efd0231aa 100644 --- a/packages/builder/src/components/start/CreateAppModal.svelte +++ b/packages/builder/src/components/start/CreateAppModal.svelte @@ -1,9 +1,8 @@