20% battery left
This commit is contained in:
@@ -3,10 +3,6 @@ import { sse } from "@/lib/utils";
|
||||
const VERSION = crypto.randomUUID();
|
||||
|
||||
export function GET({ signal }: Request) {
|
||||
sse.publish(VERSION, {
|
||||
topic: "active",
|
||||
event: "version",
|
||||
});
|
||||
// +1 because this connection is not yet counted
|
||||
sse.publish(sse.count("active") + 1, {
|
||||
topic: "active",
|
||||
@@ -18,6 +14,10 @@ export function GET({ signal }: Request) {
|
||||
// no need to -1 because this connection is already removed
|
||||
sse.publish(sse.count("active"), { topic: "active", event: "count" });
|
||||
},
|
||||
motd: {
|
||||
data: VERSION,
|
||||
event: "version",
|
||||
},
|
||||
signal,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { apiAuthCheck } from "@/lib/auth";
|
||||
import { adminCheck } from "@/lib/auth";
|
||||
import { sse } from "@/lib/utils";
|
||||
|
||||
export async function GET(
|
||||
_req: Request,
|
||||
{ params }: { params: Promise<{ topic: string }> },
|
||||
) {
|
||||
if (!(await apiAuthCheck()))
|
||||
return new Response("Unauthorized", { status: 401 });
|
||||
if (!(await adminCheck())) return new Response("Unauthorized", { status: 401 });
|
||||
const { topic } = await params;
|
||||
return sse.new(topic);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user