From b86b3d5cc19463e480c166b6b3c1f116c8ab309a Mon Sep 17 00:00:00 2001 From: josh Date: Sat, 12 Sep 2026 19:34:25 -0400 Subject: [PATCH] config upload fix --- src/routes/configs/+page.svelte | 31 ++++++++++++++++++++++--------- src/routes/plugins/+page.svelte | 26 +++++++++++++++++++------- tmp-dedicated.cfg | 16 ++++++++++++++++ tmp-resp.txt | 29 +++++++++++++++++++++++++++++ 4 files changed, 86 insertions(+), 16 deletions(-) create mode 100644 tmp-dedicated.cfg create mode 100644 tmp-resp.txt diff --git a/src/routes/configs/+page.svelte b/src/routes/configs/+page.svelte index 859e43a..194ddb1 100644 --- a/src/routes/configs/+page.svelte +++ b/src/routes/configs/+page.svelte @@ -58,15 +58,28 @@ }); async function load(): Promise { - const [baselineRes, overlayRes, scopeRes] = await Promise.all([ - fetch('/api/configs?kind=baseline'), - fetch('/api/configs?kind=config'), - fetch('/api/scope-options') - ]); - baselines = (await baselineRes.json()).scripts; - overlays = (await overlayRes.json()).scripts; - scopeOptions = (await scopeRes.json()) as ScopeOptions; - loading = false; + try { + const [baselineRes, overlayRes, scopeRes] = await Promise.all([ + fetch('/api/configs?kind=baseline'), + fetch('/api/configs?kind=config'), + fetch('/api/scope-options') + ]); + if (!baselineRes.ok || !overlayRes.ok) { + flash = `configs API returned ${baselineRes.status}/${overlayRes.status}. If this is a dev environment, restart the server so the DB migration runs.`; + baselines = []; + overlays = []; + } else { + baselines = ((await baselineRes.json()) as { scripts?: ArtifactRow[] }).scripts ?? []; + overlays = ((await overlayRes.json()) as { scripts?: ArtifactRow[] }).scripts ?? []; + } + if (scopeRes.ok) { + scopeOptions = ((await scopeRes.json()) as ScopeOptions | undefined) ?? { games: [], mapsByGame: {} }; + } + } catch (err) { + flash = `failed to load configs: ${(err as Error).message}`; + } finally { + loading = false; + } } onMount(load); diff --git a/src/routes/plugins/+page.svelte b/src/routes/plugins/+page.svelte index f900bd4..9d5ce48 100644 --- a/src/routes/plugins/+page.svelte +++ b/src/routes/plugins/+page.svelte @@ -50,13 +50,25 @@ }); async function load(): Promise { - const [pluginRes, scopeRes] = await Promise.all([ - fetch('/api/plugins'), - fetch('/api/scope-options') - ]); - plugins = (await pluginRes.json()).scripts; - scopeOptions = (await scopeRes.json()) as ScopeOptions; - loading = false; + try { + const [pluginRes, scopeRes] = await Promise.all([ + fetch('/api/plugins'), + fetch('/api/scope-options') + ]); + if (!pluginRes.ok) { + flash = `plugins API returned ${pluginRes.status}. If this is a dev environment, restart the server so the DB migration runs.`; + plugins = []; + } else { + plugins = ((await pluginRes.json()) as { scripts?: ArtifactRow[] }).scripts ?? []; + } + if (scopeRes.ok) { + scopeOptions = ((await scopeRes.json()) as ScopeOptions | undefined) ?? { games: [], mapsByGame: {} }; + } + } catch (err) { + flash = `failed to load plugins: ${(err as Error).message}`; + } finally { + loading = false; + } } onMount(load); diff --git a/tmp-dedicated.cfg b/tmp-dedicated.cfg new file mode 100644 index 0000000..2910fe5 --- /dev/null +++ b/tmp-dedicated.cfg @@ -0,0 +1,16 @@ +////////////////////////////////////////////////// +// GENERAL CONFIGURATION // +////////////////////////////////////////////////// + +set g_inactivity "190" // Enable or Disable auto kick feature for idle/AFK players. +set sv_disableClientConsole "0" // Enable or Disable players ability to access server commands +set sv_floodProtect "1" // Chat Spam Protection. +set sv_kickBanTime "300" // Kick Ban Duration. +set sv_voice "1" // Allow Voice Chat? +set sv_voicequality "3" // Voice Quality. +set sp_minplayers "1" // Minimum amount of players. +set scr_allowFileIo "1" // Allow GSC scripts to interact with files? +set scr_kill_infinite_loops "1" // Kill misbehaving threads? +set sv_wwwBaseURL "" // Fast DL URL + +set sv_maprotation "map zombie_theater" diff --git a/tmp-resp.txt b/tmp-resp.txt new file mode 100644 index 0000000..22067bd --- /dev/null +++ b/tmp-resp.txt @@ -0,0 +1,29 @@ +Note: Unnecessary use of -X or --request, POST is already inferred. +* Host localhost:3000 was resolved. +* IPv6: ::1 +* IPv4: 127.0.0.1 + % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed + 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying [::1]:3000... +* Connected to localhost (::1) port 3000 +* using HTTP/1.x +> POST /api/configs HTTP/1.1 +> Host: localhost:3000 +> User-Agent: curl/8.15.0 +> Accept: */* +> Content-Length: 1832 +> Content-Type: multipart/form-data; boundary=------------------------barYWMs19HWi81kFXmt3OX +> +} [1832 bytes data] +* upload completely sent off: 1832 bytes +< HTTP/1.1 200 OK +< Access-Control-Allow-Origin: * +< content-length: 232 +< content-type: application/json +< Date: Sat, 12 Sep 2026 23:27:36 GMT +< Connection: keep-alive +< Keep-Alive: timeout=5 +< +{ [232 bytes data] + 100 2064 100 232 100 1832 49225 379k --:--:-- --:--:-- --:--:-- 503k{"ok":true,"script":{"id":2,"name":"T5 Zombies Baseline","target_rel_path":"dedicated_sp.cfg","scope_type":"game","scope_value":"t5","current_version_id":null,"kind":"baseline","created_at":"2026-09-12T23:27:36.519Z"},"versionId":2} +* Connection #0 to host localhost left intact