mirror of
https://github.com/JezzWTF/vibepod.git
synced 2026-06-01 15:22:14 +00:00
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>
This commit is contained in:
@@ -1,5 +1,8 @@
|
|||||||
import { NextResponse } from "next/server";
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
|
const OFFLINE_RESPONSE = { status: "offline" };
|
||||||
|
const COMMON_OPTIONS = { headers: { "Cache-Control": "no-store" } };
|
||||||
|
|
||||||
export async function GET() {
|
export async function GET() {
|
||||||
const pythonServerUrl =
|
const pythonServerUrl =
|
||||||
process.env.VIBEVOICE_SERVER_URL ?? "http://localhost:8000";
|
process.env.VIBEVOICE_SERVER_URL ?? "http://localhost:8000";
|
||||||
@@ -24,17 +27,11 @@ export async function GET() {
|
|||||||
progress: data.progress ?? null,
|
progress: data.progress ?? null,
|
||||||
voices: data.voices ?? [],
|
voices: data.voices ?? [],
|
||||||
},
|
},
|
||||||
{ headers: { "Cache-Control": "no-store" } }
|
COMMON_OPTIONS
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return NextResponse.json(
|
return NextResponse.json(OFFLINE_RESPONSE, COMMON_OPTIONS);
|
||||||
{ status: "offline" },
|
|
||||||
{ headers: { "Cache-Control": "no-store" } }
|
|
||||||
);
|
|
||||||
} catch {
|
} catch {
|
||||||
return NextResponse.json(
|
return NextResponse.json(OFFLINE_RESPONSE, COMMON_OPTIONS);
|
||||||
{ status: "offline" },
|
|
||||||
{ headers: { "Cache-Control": "no-store" } }
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user