diff --git a/packages/frontend-core/src/api/app.js b/packages/frontend-core/src/api/app.js index 29309e2af3..982066f05a 100644 --- a/packages/frontend-core/src/api/app.js +++ b/packages/frontend-core/src/api/app.js @@ -128,7 +128,7 @@ export const buildAppEndpoints = API => ({ */ fetchSystemDebugInfo: async () => { return await API.get({ - url: `/api/dev/debug`, + url: `/api/debug/diagnostics`, }) }, diff --git a/packages/server/package.json b/packages/server/package.json index 6e74de6afa..11ede6d173 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -48,7 +48,7 @@ "@apidevtools/swagger-parser": "10.0.3", "@budibase/backend-core": "0.0.0", "@budibase/client": "0.0.0", - "@budibase/pro": "0.0.0", + "@budibase/pro": "develop", "@budibase/shared-core": "0.0.0", "@budibase/string-templates": "0.0.0", "@budibase/types": "0.0.0", diff --git a/packages/server/src/api/controllers/debug.ts b/packages/server/src/api/controllers/debug.ts new file mode 100644 index 0000000000..8210971749 --- /dev/null +++ b/packages/server/src/api/controllers/debug.ts @@ -0,0 +1,45 @@ +import os from "os" +import process from "process" +import { env } from "@budibase/backend-core" + +export async function systemDebugInfo(ctx: any) { + const { days, hours, minutes } = secondsToHMS(os.uptime()) + const totalMemory = convertBytes(os.totalmem()) + + ctx.body = { + budibaseVersion: env.VERSION, + hosting: env.DEPLOYMENT_ENVIRONMENT, + nodeVersion: process.version, + platform: process.platform, + cpuArch: process.arch, + cpuCores: os.cpus().length, + cpuInfo: os.cpus()[0].model, + totalMemory: `${totalMemory.gb}GB`, + uptime: `${days} day(s), ${hours} hour(s), ${minutes} minute(s)`, + } +} + +function secondsToHMS(seconds: number) { + const MINUTE_IN_SECONDS = 60 + const HOUR_IN_SECONDS = 3600 + const DAY_IN_SECONDS = HOUR_IN_SECONDS * 24 + + const minutes = Math.floor((seconds / MINUTE_IN_SECONDS) % 60) + const hours = Math.floor((seconds / HOUR_IN_SECONDS) % 24) + const days = Math.floor(seconds / DAY_IN_SECONDS) + + return { + days, + hours, + minutes, + seconds, + } +} + +function convertBytes(bytes: number) { + const kb = bytes / 1024 + const mb = kb / 1024 + const gb = mb / 1024 + + return { gb, mb, kb } +} diff --git a/packages/server/src/api/controllers/dev.ts b/packages/server/src/api/controllers/dev.ts index c1b568179e..e80d9d7ea1 100644 --- a/packages/server/src/api/controllers/dev.ts +++ b/packages/server/src/api/controllers/dev.ts @@ -1,7 +1,5 @@ import fetch from "node-fetch" import env from "../../environment" -import os from "os" -import process from "process" import { checkSlashesInUrl } from "../../utilities" import { request } from "../../utilities/workerRequests" import { clearLock as redisClearLock } from "../../utilities/redis" @@ -129,45 +127,3 @@ export async function getBudibaseVersion(ctx: any) { } await events.installation.versionChecked(version) } - -export async function systemDebugInfo(ctx: any) { - const { days, hours, minutes } = secondsToHMS(os.uptime()) - const totalMemory = convertBytes(os.totalmem()) - - ctx.body = { - budibaseVersion: envCore.VERSION, - hosting: envCore.DEPLOYMENT_ENVIRONMENT, - nodeVersion: process.version, - platform: process.platform, - cpuArch: process.arch, - cpuCores: os.cpus().length, - cpuInfo: os.cpus()[0].model, - totalMemory: `${totalMemory.gb}GB`, - uptime: `${days} day(s), ${hours} hour(s), ${minutes} minute(s)`, - } -} - -function secondsToHMS(seconds: number) { - const MINUTE_IN_SECONDS = 60 - const HOUR_IN_SECONDS = 3600 - const DAY_IN_SECONDS = HOUR_IN_SECONDS * 24 - - const minutes = Math.floor((seconds / MINUTE_IN_SECONDS) % 60) - const hours = Math.floor((seconds / HOUR_IN_SECONDS) % 24) - const days = Math.floor(seconds / DAY_IN_SECONDS) - - return { - days, - hours, - minutes, - seconds, - } -} - -function convertBytes(bytes: number) { - const kb = bytes / 1024 - const mb = kb / 1024 - const gb = mb / 1024 - - return { gb, mb, kb } -} diff --git a/packages/server/src/api/routes/debug.ts b/packages/server/src/api/routes/debug.ts new file mode 100644 index 0000000000..5a7b9f242e --- /dev/null +++ b/packages/server/src/api/routes/debug.ts @@ -0,0 +1,14 @@ +import Router from "@koa/router" +import * as controller from "../controllers/debug" +import authorized from "../../middleware/authorized" +import { permissions } from "@budibase/backend-core" + +const router: Router = new Router() + +router.get( + "/api/debug/diagnostics", + authorized(permissions.BUILDER), + controller.systemDebugInfo +) + +export default router diff --git a/packages/server/src/api/routes/dev.ts b/packages/server/src/api/routes/dev.ts index 36d93cc777..78b79f9229 100644 --- a/packages/server/src/api/routes/dev.ts +++ b/packages/server/src/api/routes/dev.ts @@ -24,11 +24,6 @@ router authorized(permissions.BUILDER), controller.getBudibaseVersion ) - .get( - "/api/dev/debug", - authorized(permissions.BUILDER), - controller.systemDebugInfo - ) .delete( "/api/dev/:appId/lock", authorized(permissions.BUILDER), diff --git a/packages/server/src/api/routes/index.ts b/packages/server/src/api/routes/index.ts index f5374465d0..22d0a20c9b 100644 --- a/packages/server/src/api/routes/index.ts +++ b/packages/server/src/api/routes/index.ts @@ -25,6 +25,7 @@ import devRoutes from "./dev" import migrationRoutes from "./migrations" import pluginRoutes from "./plugin" import opsRoutes from "./ops" +import debugRoutes from "./debug" import Router from "@koa/router" import { api as pro } from "@budibase/pro" @@ -63,6 +64,7 @@ export const mainRoutes: Router[] = [ migrationRoutes, pluginRoutes, opsRoutes, + debugRoutes, scheduleRoutes, environmentVariableRoutes, // these need to be handled last as they still use /api/:tableId diff --git a/packages/worker/package.json b/packages/worker/package.json index b11512f88f..5c35f60454 100644 --- a/packages/worker/package.json +++ b/packages/worker/package.json @@ -39,7 +39,7 @@ "license": "GPL-3.0", "dependencies": { "@budibase/backend-core": "0.0.0", - "@budibase/pro": "0.0.0", + "@budibase/pro": "develop", "@budibase/string-templates": "0.0.0", "@budibase/types": "0.0.0", "@koa/router": "8.0.8", diff --git a/yarn.lock b/yarn.lock index ea9823b58b..742746dd51 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1728,6 +1728,45 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== +"@budibase/backend-core@2.8.2-alpha.3": + version "0.0.0" + dependencies: + "@budibase/nano" "10.1.2" + "@budibase/pouchdb-replication-stream" "1.2.10" + "@budibase/types" "0.0.0" + "@shopify/jest-koa-mocks" "5.0.1" + "@techpass/passport-openidconnect" "0.3.2" + aws-cloudfront-sign "2.2.0" + aws-sdk "2.1030.0" + bcrypt "5.0.1" + bcryptjs "2.4.3" + bull "4.10.1" + correlation-id "4.0.0" + dotenv "16.0.1" + emitter-listener "1.1.2" + ioredis "5.3.2" + joi "17.6.0" + jsonwebtoken "9.0.0" + koa-passport "4.1.4" + koa-pino-logger "4.0.0" + lodash "4.17.21" + lodash.isarguments "3.1.0" + node-fetch "2.6.7" + passport-google-oauth "2.0.0" + passport-jwt "4.0.0" + passport-local "1.0.0" + passport-oauth2-refresh "^2.1.0" + pino "8.11.0" + pino-http "8.3.3" + posthog-node "1.3.0" + pouchdb "7.3.0" + pouchdb-find "7.2.2" + redlock "4.2.0" + sanitize-s3-objectkey "0.0.1" + semver "7.3.7" + tar-fs "2.1.1" + uuid "8.3.2" + "@budibase/bbui@^0.9.139": version "0.9.190" resolved "https://registry.yarnpkg.com/@budibase/bbui/-/bbui-0.9.190.tgz#e1ec400ac90f556bfbc80fc23a04506f1585ea81" @@ -1828,6 +1867,30 @@ pouchdb-promise "^6.0.4" through2 "^2.0.0" +"@budibase/pro@develop": + version "2.8.2-alpha.3" + resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-2.8.2-alpha.3.tgz#e86abbdb4d629f129564b6809caa51e53fda935e" + integrity sha512-sXdHkWN2VC7tL1mQ1xZv7Q3E4geugkbU12Z6i4yRcivEYRaFAtWXyRL99bGQSFpFaeCGYl0DArL/ql4taB6sUw== + dependencies: + "@budibase/backend-core" "2.8.2-alpha.3" + "@budibase/shared-core" "2.8.2-alpha.3" + "@budibase/string-templates" "2.8.2-alpha.3" + "@budibase/types" "2.8.2-alpha.3" + "@koa/router" "8.0.8" + bull "4.10.1" + joi "17.6.0" + jsonwebtoken "8.5.1" + lru-cache "^7.14.1" + memorystream "^0.3.1" + node-fetch "^2.6.1" + scim-patch "^0.7.0" + scim2-parse-filter "^0.2.8" + +"@budibase/shared-core@2.8.2-alpha.3": + version "0.0.0" + dependencies: + "@budibase/types" "0.0.0" + "@budibase/standard-components@^0.9.139": version "0.9.139" resolved "https://registry.yarnpkg.com/@budibase/standard-components/-/standard-components-0.9.139.tgz#cf8e2b759ae863e469e50272b3ca87f2827e66e3" @@ -1846,6 +1909,21 @@ svelte-apexcharts "^1.0.2" svelte-flatpickr "^3.1.0" +"@budibase/string-templates@2.8.2-alpha.3": + version "0.0.0" + dependencies: + "@budibase/handlebars-helpers" "^0.11.8" + dayjs "^1.10.4" + handlebars "^4.7.6" + handlebars-utils "^1.0.6" + lodash "^4.17.20" + vm2 "^3.9.15" + +"@budibase/types@2.8.2-alpha.3": + version "0.0.0" + dependencies: + scim-patch "^0.7.0" + "@bull-board/api@3.7.0": version "3.7.0" resolved "https://registry.yarnpkg.com/@bull-board/api/-/api-3.7.0.tgz#231f687187c0cb34e0b97f463917b6aaeb4ef6af" @@ -3545,11 +3623,6 @@ resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz#add4c98d341472a289190b424efbdb096991bb24" integrity sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw== -"@jridgewell/sourcemap-codec@^1.4.13": - version "1.4.15" - resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz#d7c6e6755c78567a951e04ab52ef0fd26de59f32" - integrity sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg== - "@jridgewell/trace-mapping@0.3.9": version "0.3.9" resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz#6534fd5933a53ba7cbf3a17615e273a0d1273ff9" @@ -4335,7 +4408,7 @@ dependencies: slash "^3.0.0" -"@rollup/plugin-commonjs@16.0.0", "@rollup/plugin-commonjs@^16.0.0": +"@rollup/plugin-commonjs@^16.0.0": version "16.0.0" resolved "https://registry.yarnpkg.com/@rollup/plugin-commonjs/-/plugin-commonjs-16.0.0.tgz#169004d56cd0f0a1d0f35915d31a036b0efe281f" integrity sha512-LuNyypCP3msCGVQJ7ki8PqYdpjfEkE/xtFa5DqlF+7IBD0JsfMZ87C58heSwIMint58sAUZbt3ITqOmdQv/dXw== @@ -4418,22 +4491,6 @@ "@rollup/pluginutils" "^3.1.0" magic-string "^0.25.7" -"@rollup/plugin-replace@^5.0.2": - version "5.0.2" - resolved "https://registry.yarnpkg.com/@rollup/plugin-replace/-/plugin-replace-5.0.2.tgz#45f53501b16311feded2485e98419acb8448c61d" - integrity sha512-M9YXNekv/C/iHHK+cvORzfRYfPbq0RDD8r0G+bMiTXjNGKulPnCT9O3Ss46WfhI6ZOCgApOP7xAdmCQJ+U2LAA== - dependencies: - "@rollup/pluginutils" "^5.0.1" - magic-string "^0.27.0" - -"@rollup/plugin-typescript@8.3.0": - version "8.3.0" - resolved "https://registry.yarnpkg.com/@rollup/plugin-typescript/-/plugin-typescript-8.3.0.tgz#bc1077fa5897b980fc27e376c4e377882c63e68b" - integrity sha512-I5FpSvLbtAdwJ+naznv+B4sjXZUcIvLLceYpITAn7wAP8W0wqc5noLdGIp9HGVntNhRWXctwPYrSSFQxtl0FPA== - dependencies: - "@rollup/pluginutils" "^3.1.0" - resolve "^1.17.0" - "@rollup/pluginutils@^3.0.8", "@rollup/pluginutils@^3.1.0": version "3.1.0" resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-3.1.0.tgz#706b4524ee6dc8b103b3c995533e5ad680c02b9b" @@ -5659,13 +5716,6 @@ resolved "https://registry.yarnpkg.com/@types/http-errors/-/http-errors-2.0.1.tgz#20172f9578b225f6c7da63446f56d4ce108d5a65" integrity sha512-/K3ds8TRAfBvi5vfjuz8y6+GiAYBZ0x4tXv1Av6CWBWn0IlADc+ZX9pMq7oU0fNQPnBwIZl3rmeLp6SBApbxSQ== -"@types/ioredis@4.28.10": - version "4.28.10" - resolved "https://registry.yarnpkg.com/@types/ioredis/-/ioredis-4.28.10.tgz#40ceb157a4141088d1394bb87c98ed09a75a06ff" - integrity sha512-69LyhUgrXdgcNDv7ogs1qXZomnfOEnSmrmMFqKgt1XMJxmoOSG/u3wYy13yACIfKuMJ8IhKgHafDO3sx19zVQQ== - dependencies: - "@types/node" "*" - "@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0", "@types/istanbul-lib-coverage@^2.0.1": version "2.0.4" resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz#8467d4b3c087805d63580480890791277ce35c44" @@ -12463,7 +12513,7 @@ fs.realpath@^1.0.0: resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== -fsevents@^2.1.2, fsevents@^2.3.2, fsevents@~2.3.1, fsevents@~2.3.2: +fsevents@^2.1.2, fsevents@^2.3.2, fsevents@~2.3.2: version "2.3.2" resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== @@ -13668,13 +13718,6 @@ husky@^8.0.3: resolved "https://registry.yarnpkg.com/husky/-/husky-8.0.3.tgz#4936d7212e46d1dea28fef29bb3a108872cd9184" integrity sha512-+dQSyqPh4x1hlO1swXBiNb2HzTDN1I2IGLQx1GrBuiqFJfoMrnZWwVmatvSiO+Iz8fBUnf+lekwNo4c2LlXItg== -ical-generator@4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/ical-generator/-/ical-generator-4.1.0.tgz#2a336c951864c5583a2aa715d16f2edcdfd2d90b" - integrity sha512-5GrFDJ8SAOj8cB9P1uEZIfKrNxSZ1R2eOQfZePL+CtdWh4RwNXWe8b0goajz+Hu37vcipG3RVldoa2j57Y20IA== - dependencies: - uuid-random "^1.3.2" - iconv-lite@0.4.24, iconv-lite@^0.4.15, iconv-lite@^0.4.24, iconv-lite@^0.4.5: version "0.4.24" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" @@ -17507,13 +17550,6 @@ magic-string@^0.26.2: dependencies: sourcemap-codec "^1.4.8" -magic-string@^0.27.0: - version "0.27.0" - resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.27.0.tgz#e4a3413b4bab6d98d2becffd48b4a257effdbbf3" - integrity sha512-8UnnX2PeRAPZuN12svgR9j7M1uWMovg/CEnIwIG0LFkXSJJe4PdfUGiTGl8V9bsBHFUtfVINcSyYxd7q+kx9fA== - dependencies: - "@jridgewell/sourcemap-codec" "^1.4.13" - make-dir@3.1.0, make-dir@^3.0.0, make-dir@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-3.1.0.tgz#415e967046b3a7f1d185277d84aa58203726a13f" @@ -22352,13 +22388,6 @@ rollup-pluginutils@^2.3.1, rollup-pluginutils@^2.5.0, rollup-pluginutils@^2.6.0, dependencies: estree-walker "^0.6.1" -rollup@2.45.2: - version "2.45.2" - resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.45.2.tgz#8fb85917c9f35605720e92328f3ccbfba6f78b48" - integrity sha512-kRRU7wXzFHUzBIv0GfoFFIN3m9oteY4uAsKllIpQDId5cfnkWF2J130l+27dzDju0E6MScKiV0ZM5Bw8m4blYQ== - optionalDependencies: - fsevents "~2.3.1" - rollup@^2.36.2, rollup@^2.44.0, rollup@^2.45.2, rollup@^2.79.1: version "2.79.1" resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.79.1.tgz#bedee8faef7c9f93a2647ac0108748f497f081c7" @@ -24388,7 +24417,7 @@ timed-out@^4.0.1: resolved "https://registry.yarnpkg.com/timed-out/-/timed-out-4.0.1.tgz#f32eacac5a175bea25d7fab565ab3ed8741ef56f" integrity sha512-G7r3AhovYtr5YKOWQkta8RKAPb+J9IsO4uVmzjl8AZwfhs8UcUwTiD6gcJYSgOtzyjvQKrKYn41syHbUWMkafA== -timekeeper@2.2.0, timekeeper@^2.2.0: +timekeeper@2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/timekeeper/-/timekeeper-2.2.0.tgz#9645731fce9e3280a18614a57a9d1b72af3ca368" integrity sha512-W3AmPTJWZkRwu+iSNxPIsLZ2ByADsOLbbLxe46UJyWj3mlYLlwucKiq+/dPm0l9wTzqoF3/2PH0AGFCebjq23A== @@ -25286,11 +25315,6 @@ utils-merge@1.0.1, utils-merge@1.x.x: resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" integrity sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA== -uuid-random@^1.3.2: - version "1.3.2" - resolved "https://registry.yarnpkg.com/uuid-random/-/uuid-random-1.3.2.tgz#96715edbaef4e84b1dcf5024b00d16f30220e2d0" - integrity sha512-UOzej0Le/UgkbWEO8flm+0y+G+ljUon1QWTEZOq1rnMAsxo2+SckbiZdKzAHHlVh6gJqI1TjC/xwgR50MuCrBQ== - uuid@3.3.2: version "3.3.2" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.2.tgz#1b4af4955eb3077c501c23872fc6513811587131"