From 7a1fc23e5a86781e2e401c47dec784df8c37c787 Mon Sep 17 00:00:00 2001 From: tobinio Date: Mon, 17 Jun 2024 21:53:29 +0200 Subject: [PATCH] load data from modrinth --- composables/useModrinthFetch.ts | 11 +++ layouts/default.vue | 19 +++- pages/downloads.vue | 3 + pages/index.vue | 3 +- pages/majorVersionDownloads.vue | 52 ++++++++++ pages/minorVersionDownloads.vue | 52 ++++++++++ server/api/downloads.ts | 42 ++++---- server/api/majorVersionDownloads.ts | 35 +++++++ server/api/minorVersionDownloads.ts | 35 +++++++ server/api/update.ts | 147 ++++++++++++++++++++++++++++ server/utils/color.ts | 4 +- server/utils/fetchData.ts | 56 +++++++++++ server/utils/types/downloads.ts | 7 ++ utils/modrinthFetch.ts | 4 + 14 files changed, 445 insertions(+), 25 deletions(-) create mode 100644 composables/useModrinthFetch.ts create mode 100644 pages/majorVersionDownloads.vue create mode 100644 pages/minorVersionDownloads.vue create mode 100644 server/api/majorVersionDownloads.ts create mode 100644 server/api/minorVersionDownloads.ts create mode 100644 server/api/update.ts create mode 100644 server/utils/fetchData.ts create mode 100644 server/utils/types/downloads.ts create mode 100644 utils/modrinthFetch.ts diff --git a/composables/useModrinthFetch.ts b/composables/useModrinthFetch.ts new file mode 100644 index 0000000..4779ace --- /dev/null +++ b/composables/useModrinthFetch.ts @@ -0,0 +1,11 @@ +import type {UseFetchOptions} from "#app"; + +export function useModrinthFetch( + url: string | (() => string), + options: UseFetchOptions = {} +) { + return useFetch(url, { + ...options, + $fetch: $modrinthFetch, + }) +} \ No newline at end of file diff --git a/layouts/default.vue b/layouts/default.vue index 61351ef..9b2314a 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -1,5 +1,7 @@