20% battery left

This commit is contained in:
Dreamgineer
2025-11-18 16:24:00 -05:00 Unverified
parent 27b8336295
commit fb031da1ef
19 changed files with 262 additions and 74 deletions
+4 -4
View File
@@ -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,
});
}
+2 -3
View File
@@ -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);
}