feat: add deployment reload controls

This commit is contained in:
2026-08-23 14:33:26 +00:00 Unverified
parent 25dccdfa4f
commit a630e0cc2f
11 changed files with 341 additions and 32 deletions
+28
View File
@@ -0,0 +1,28 @@
import { readFile } from "node:fs/promises";
import path from "node:path";
import { sse } from "@/lib/realtime/sse";
export const dynamic = "force-dynamic";
async function getDeploymentVersion() {
if (process.env.NODE_ENV === "development") return "DEV";
try {
const version = await readFile(path.join(process.cwd(), ".version"), "utf8");
return version.trim() || null;
} catch {
return null;
}
}
export async function GET(request: Request) {
const version = await getDeploymentVersion();
if (!version) {
return new Response("Deployment version unavailable", { status: 503 });
}
return sse.active.stream({
signal: request.signal,
motd: { event: "version", data: version },
});
}