From bd5c6673076d875bdb777153bd4022cf86363216 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 28 Apr 2026 14:17:19 +0000 Subject: [PATCH] chore: refactor duplicated offline response in health api route Extract the duplicated offline response payload and common headers into constants to improve maintainability and readability. - Define OFFLINE_RESPONSE for { status: "offline" } - Define COMMON_OPTIONS for { headers: { "Cache-Control": "no-store" } } - Use these constants across all response paths in the route. Co-authored-by: LyAhn <27559362+LyAhn@users.noreply.github.com> --- web/app/api/health/route.ts | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/web/app/api/health/route.ts b/web/app/api/health/route.ts index 097cb95..05c2de8 100644 --- a/web/app/api/health/route.ts +++ b/web/app/api/health/route.ts @@ -1,5 +1,8 @@ import { NextResponse } from "next/server"; +const OFFLINE_RESPONSE = { status: "offline" }; +const COMMON_OPTIONS = { headers: { "Cache-Control": "no-store" } }; + export async function GET() { const pythonServerUrl = process.env.VIBEVOICE_SERVER_URL ?? "http://localhost:8000"; @@ -24,17 +27,11 @@ export async function GET() { progress: data.progress ?? null, voices: data.voices ?? [], }, - { headers: { "Cache-Control": "no-store" } } + COMMON_OPTIONS ); } - return NextResponse.json( - { status: "offline" }, - { headers: { "Cache-Control": "no-store" } } - ); + return NextResponse.json(OFFLINE_RESPONSE, COMMON_OPTIONS); } catch { - return NextResponse.json( - { status: "offline" }, - { headers: { "Cache-Control": "no-store" } } - ); + return NextResponse.json(OFFLINE_RESPONSE, COMMON_OPTIONS); } }