From 172274b8091e8925fc53d19bd8a58171dfec00be Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Thu, 6 Jul 2023 16:18:40 -0400 Subject: [PATCH] fix auto update route --- web/app/api/update/route.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/web/app/api/update/route.ts b/web/app/api/update/route.ts index 8e7d0ecc..9199db21 100644 --- a/web/app/api/update/route.ts +++ b/web/app/api/update/route.ts @@ -11,6 +11,10 @@ export async function GET(req: Request) { const os = searchParams.get('os') || '' const version = searchParams.get('version') || '' + if (!version) { + return new Response('not found', { status: 404 }) + } + try { const { data } = await octokit.repos.getLatestRelease({ owner: 'jmorganca', @@ -21,12 +25,14 @@ export async function GET(req: Request) { const asset = data.assets.find(a => a.name.toLowerCase().includes(os)) if (!asset) { - return new Response('up to date', { status: 204 }) + return new Response('not found', { status: 404 }) } if (semver.lt(version, data.tag_name)) { return NextResponse.json({ version: data.tag_name, url: asset.browser_download_url }) } + + return new Response('up to date', { status: 204 }) } catch (error) { const e = error as RequestError if (e.status === 404) { @@ -35,6 +41,4 @@ export async function GET(req: Request) { return new Response('internal server error', { status: 500 }) } - - return new Response('up to date', { status: 204 }) }