From 51f047df3ebb38c0b68e19675d007b1e31382c9f Mon Sep 17 00:00:00 2001 From: Falkan Date: Tue, 17 Mar 2026 20:39:51 -0400 Subject: [PATCH] =?UTF-8?q?revert:=20undo=20adminPath=20routing=20attempts?= =?UTF-8?q?=20=E2=80=94=20clean=20slate=20for=20restart?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/.config.json.swp | Bin 1024 -> 0 bytes data/units.json | 16 ------------ src/hooks.server.ts | 10 -------- src/hooks.ts | 40 ----------------------------- src/routes/admin/+layout.server.ts | 5 +--- src/routes/admin/+page.svelte | 2 -- 6 files changed, 1 insertion(+), 72 deletions(-) delete mode 100644 data/.config.json.swp delete mode 100644 src/hooks.server.ts delete mode 100644 src/hooks.ts diff --git a/data/.config.json.swp b/data/.config.json.swp deleted file mode 100644 index 886da715b35ab227bddafff4d9ce9438689d8ee4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1024 zcmYc?$V<%2SFq4CVL$=fn%Nlg^7HZ%QADwGQc{yL6Z3Qpjj>C^MN<+>67`ew^U^ZY V^|Ffd^WYMrjL{Gn4S@j(0RXfc4{ZPd diff --git a/data/units.json b/data/units.json index d03b109..554be37 100644 --- a/data/units.json +++ b/data/units.json @@ -71,22 +71,6 @@ "symbol": "mfcktn", "group": "dickloads", "toBase": 170.2399999998 - }, - { - "id": "shitload", - "label": "Shitload", - "labelPlural": "Shitloads", - "symbol": "shtld", - "group": "dickloads", - "toBase": 12.6666666667 - }, - { - "id": "shit-ton", - "label": "Shit ton", - "labelPlural": "Shit tons", - "symbol": "shttn", - "group": "dickloads", - "toBase": 25.3333333333 } ], "groups": [ diff --git a/src/hooks.server.ts b/src/hooks.server.ts deleted file mode 100644 index c15fdc2..0000000 --- a/src/hooks.server.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { loadConfig } from '$lib/server/data'; -import type { Handle } from '@sveltejs/kit'; - -/** - * handle: no URL rewriting here (that's reroute in hooks.ts). - * Kept as a placeholder for future server-only middleware. - */ -export const handle: Handle = async ({ event, resolve }) => { - return resolve(event); -}; diff --git a/src/hooks.ts b/src/hooks.ts deleted file mode 100644 index 3059b55..0000000 --- a/src/hooks.ts +++ /dev/null @@ -1,40 +0,0 @@ -import type { Reroute } from '@sveltejs/kit'; - -/** - * reroute: rewrites the configured adminPath to the internal /admin route. - * Reads config.json directly (not via $lib/server/data) so this universal - * hook can run server-side without triggering the browser-import guard. - * - * Example: adminPath = "boss" - * /boss → /admin - * /boss/login → /admin/login - * /boss/api/... → /admin/api/... - */ -export const reroute: Reroute = ({ url }) => { - // Only runs on the server — typeof window is undefined here during SSR/Node. - // In the browser, SvelteKit client-side routing never calls reroute for - // server routes, so this branch is safe to guard. - if (typeof window !== 'undefined') return url.pathname; - - try { - // Dynamic require so bundler doesn't try to resolve at build time - // eslint-disable-next-line @typescript-eslint/no-require-imports - const fs = require('fs') as typeof import('fs'); - // eslint-disable-next-line @typescript-eslint/no-require-imports - const path = require('path') as typeof import('path'); - const configPath = path.resolve('data', 'config.json'); - const config = JSON.parse(fs.readFileSync(configPath, 'utf8')) as { adminPath?: string }; - const adminPath = (config.adminPath ?? 'admin').replace(/^\/|\/$/g, ''); - - if (adminPath === 'admin') return url.pathname; - - const prefix = `/${adminPath}`; - if (url.pathname === prefix || url.pathname.startsWith(prefix + '/')) { - return '/admin' + url.pathname.slice(prefix.length); - } - } catch { - // If config can't be read, fall through to default routing - } - - return url.pathname; -}; diff --git a/src/routes/admin/+layout.server.ts b/src/routes/admin/+layout.server.ts index cb62807..bfb46d4 100644 --- a/src/routes/admin/+layout.server.ts +++ b/src/routes/admin/+layout.server.ts @@ -1,6 +1,5 @@ import { redirect } from '@sveltejs/kit'; import { authRequest } from '$lib/server/auth'; -import { loadConfig } from '$lib/server/data'; import type { LayoutServerLoad } from './$types'; export const load: LayoutServerLoad = ({ request, url }) => { @@ -15,9 +14,7 @@ export const load: LayoutServerLoad = ({ request, url }) => { } if (!authRequest(request)) { - // Redirect to login using the configured admin path so the URL stays consistent - const adminPath = (loadConfig().adminPath ?? 'admin').replace(/^\/|\/$/g, ''); - throw redirect(302, `/${adminPath}/login`); + throw redirect(302, '/admin/login'); } return { authenticated: true }; diff --git a/src/routes/admin/+page.svelte b/src/routes/admin/+page.svelte index 4cb9d17..ebfe9f8 100644 --- a/src/routes/admin/+page.svelte +++ b/src/routes/admin/+page.svelte @@ -771,8 +771,6 @@ > onUnitDragStart(e, unit.id, null)} ondragend={onUnitDragEnd}