From 92150c575fd4157b3daa5752c27712c5ced3af7b Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Thu, 15 Sep 2022 15:23:08 -0700 Subject: [PATCH] move codeberg fetch to backend --- package.json | 2 +- packages/backend/src/server/api/endpoints.ts | 4 +++- .../src/server/api/endpoints/latest-version.ts | 7 +++++++ packages/client/src/pages/admin/index.vue | 12 +++--------- 4 files changed, 14 insertions(+), 11 deletions(-) create mode 100644 packages/backend/src/server/api/endpoints/latest-version.ts diff --git a/package.json b/package.json index a0f00e8b01..14528c7422 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "calckey", - "version": "12.119.0-calc.1-rc.6", + "version": "12.119.0-calc.1-rc.7", "codename": "aqua", "repository": { "type": "git", diff --git a/packages/backend/src/server/api/endpoints.ts b/packages/backend/src/server/api/endpoints.ts index 208542ed3a..08dfa44a1e 100644 --- a/packages/backend/src/server/api/endpoints.ts +++ b/packages/backend/src/server/api/endpoints.ts @@ -272,6 +272,7 @@ import * as ep___recommendedInstances from './endpoints/recommended-instances.js import * as ep___pinnedUsers from './endpoints/pinned-users.js'; import * as ep___customMOTD from './endpoints/custom-motd.js'; import * as ep___customSplashIcons from './endpoints/custom-splash-icons.js'; +import * as ep___latestVersion from './endpoints/latest-version.js'; import * as ep___promo_read from './endpoints/promo/read.js'; import * as ep___requestResetPassword from './endpoints/request-reset-password.js'; import * as ep___resetDb from './endpoints/reset-db.js'; @@ -592,7 +593,8 @@ const eps = [ ['pinned-users', ep___pinnedUsers], ['recommended-instances', ep___recommendedInstances], ['custom-motd', ep___customMOTD], - ['custom-motd', ep___customSplashIcons], + ['custom-splash-icons', ep___customSplashIcons], + ['latest-version', ep___latestVersion], ['promo/read', ep___promo_read], ['request-reset-password', ep___requestResetPassword], ['reset-db', ep___resetDb], diff --git a/packages/backend/src/server/api/endpoints/latest-version.ts b/packages/backend/src/server/api/endpoints/latest-version.ts new file mode 100644 index 0000000000..7819fdf192 --- /dev/null +++ b/packages/backend/src/server/api/endpoints/latest-version.ts @@ -0,0 +1,7 @@ +export async function getLatestVersion(): Promise { + let tag_name = 'v12.119.0-calc'; + fetch('https://codeberg.org/api/v1/repos/thatonecalculator/calckey/releases?draft=false&pre-release=false&page=1&limit=1') + .then((response) => response.json()) + .then((data) => { tag_name = data[0].tag_name; }); + return tag_name; +} diff --git a/packages/client/src/pages/admin/index.vue b/packages/client/src/pages/admin/index.vue index baed758a8c..e78c2557b2 100644 --- a/packages/client/src/pages/admin/index.vue +++ b/packages/client/src/pages/admin/index.vue @@ -68,15 +68,9 @@ os.api('admin/abuse-user-reports', { if (reports?.length > 0) thereIsUnresolvedAbuseReport = true; }); -await fetch('https://codeberg.org/api/v1/repos/thatonecalculator/calckey/releases?draft=false&pre-release=false&page=1&limit=1') - .then((response) => response.json()) - .then((data) => { - console.log(data); - console.log(data[0]); - if (data[0].tag_name !== version) { - updateAvailable = true; - } - }); +os.api('latest-version').then(res => { + console.log(res); +}); const NARROW_THRESHOLD = 600; const ro = new ResizeObserver((entries, observer) => {