From c505543a7347e3218779111d51aab54626d49f05 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Wed, 30 Nov 2022 16:17:20 -0500 Subject: [PATCH] feat: Additional instance configuration (#260) --- composables/users.ts | 4 ++++ nuxt.config.ts | 4 ++++ server/shared.ts | 5 +++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/composables/users.ts b/composables/users.ts index 284d0110..bc605b9f 100644 --- a/composables/users.ts +++ b/composables/users.ts @@ -39,6 +39,10 @@ export async function loginTo(user?: Omit & { account?: Ac const masto = await loginMasto({ url: `https://${user?.server || DEFAULT_SERVER}`, accessToken: user?.token, + // Masto uses Mastodon version checks to see what features are enabled. + // Mastodon alternatives like GoToSocial will always fail these checks, so + // provide a way to disable them. + disableVersionCheck: process.env.MASTO_DISABLE_VERSION_CHECK === 'true', }) if (!user?.token) { diff --git a/nuxt.config.ts b/nuxt.config.ts index 85c766ce..61d64796 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -60,6 +60,10 @@ export default defineNuxtConfig({ public: { translateApi: '', }, + storage: { + driver: process.env.ELK_STORAGE_DRIVER || 'cloudflare', // 'cloudflare' | 'fs' + fsBase: process.env.ELK_STORAGE_PATH ?? 'node_modules/.cache/servers', + }, }, nitro: { prerender: { diff --git a/server/shared.ts b/server/shared.ts index 70353835..bd099646 100644 --- a/server/shared.ts +++ b/server/shared.ts @@ -21,8 +21,8 @@ const kv = _kv as typeof import('unstorage/dist/drivers/cloudflare-kv-http')['de const storage = useStorage() as Storage -if (config.env === 'local') { - storage.mount('servers', fs({ base: 'node_modules/.cache/servers' })) +if (config.env === 'local' || config.storage.driver === 'fs') { + storage.mount('servers', fs({ base: config.storage.fsBase })) } else { storage.mount('servers', cached(kv({ @@ -31,6 +31,7 @@ else { apiToken: config.cloudflare.apiToken, }))) } + export function getRedirectURI(server: string) { return `${HOST_URL}/api/${server}/oauth` }