feat(deploy): notify clients of new releases
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import { connection } from "next/server";
|
||||
|
||||
import { normalizeDeploymentId } from "@/lib/deployment/version";
|
||||
import { createEventStream, eventStreamHeaders } from "@/lib/events/sse";
|
||||
|
||||
export async function GET(request: Request) {
|
||||
await connection();
|
||||
const deploymentId =
|
||||
normalizeDeploymentId(process.env.NEXT_DEPLOYMENT_ID) ?? "development";
|
||||
const channel = createEventStream({ signal: request.signal });
|
||||
channel.sendNamed("deployment", deploymentId);
|
||||
|
||||
return new Response(channel.stream, {
|
||||
headers: eventStreamHeaders(),
|
||||
});
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { Metadata } from "next";
|
||||
import { Anuphan, Geist_Mono } from "next/font/google";
|
||||
|
||||
import { DeploymentUpdateNotifier } from "@/components/deployment-update-notifier";
|
||||
import { Toaster } from "@/components/ui/sonner";
|
||||
import { TooltipProvider } from "@/components/ui/tooltip";
|
||||
|
||||
@@ -26,6 +27,9 @@ export const metadata: Metadata = {
|
||||
};
|
||||
|
||||
export default function RootLayout({ children }: LayoutProps<"/">) {
|
||||
const deploymentId =
|
||||
process.env.NEXT_DEPLOYMENT_ID?.trim() || "development";
|
||||
|
||||
return (
|
||||
<html
|
||||
lang="th"
|
||||
@@ -34,6 +38,7 @@ export default function RootLayout({ children }: LayoutProps<"/">) {
|
||||
<body className="flex min-h-full flex-col">
|
||||
<TooltipProvider>
|
||||
{children}
|
||||
<DeploymentUpdateNotifier deploymentId={deploymentId} />
|
||||
<Toaster position="bottom-right" />
|
||||
</TooltipProvider>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user