feat: proxy POST /model/unload endpoint
All checks were successful
Build & Push Docker Image / build-and-push (push) Successful in 43s

- Add unloadModel() to whisper.ts: POSTs to /model/unload with 10s
  timeout, returns parsed JSON body, throws on non-ok response
- Create src/routes/api/model/unload/+server.ts: thin POST proxy,
  passes whisper's response through, returns 502 if whisper unreachable
- Add 3 unloadModel tests (success, WHISPER_URL config, error propagation)
  — 147/147 passing

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Giancarmine Salucci
2026-05-09 15:48:47 +02:00
parent 04142b17a8
commit 53f874aec7
3 changed files with 61 additions and 1 deletions

View File

@@ -0,0 +1,13 @@
import { json } from '@sveltejs/kit';
import { unloadModel } from '$lib/server/whisper.js';
/** Proxy for POST /model/unload on the whisper backend. */
export async function POST() {
try {
const body = await unloadModel();
return json(body);
} catch (err: unknown) {
const message = err instanceof Error ? err.message : String(err);
return json({ ok: false, error: message }, { status: 502 });
}
}