feat: type-safe SSE rewrite

This commit is contained in:
2026-04-09 04:52:14 +07:00 Unverified
parent a59784e9d2
commit 94af52648c
16 changed files with 263 additions and 271 deletions
+3 -3
View File
@@ -1,10 +1,10 @@
import { ps } from "@/lib/db/redis";
import { sse } from "@/lib/db/sse-endpoints";
const version = Bun.file(".version");
export async function GET(req: Request) {
if (process.env.ENVIRONMENT === "development")
return ps.new("active", {
return sse.active.stream({
motd: {
data: "DEV",
event: "version",
@@ -17,7 +17,7 @@ export async function GET(req: Request) {
ver = crypto.randomUUID();
await version.write(crypto.randomUUID());
}
return ps.new("active", {
return sse.active.stream({
motd: {
data: ver,
event: "version",
-5
View File
@@ -1,5 +0,0 @@
import { ps } from "@/lib/db/redis";
export async function GET() {
return ps.new("artifact");
}
-12
View File
@@ -1,12 +0,0 @@
import { adminCheck } from "@/lib/auth";
import { ps } from "@/lib/db/redis";
export async function GET(
_req: Request,
{ params }: { params: Promise<{ topic: string }> },
) {
if (!(await adminCheck()))
return new Response("Unauthorized", { status: 401 });
const { topic } = await params;
return ps.new(topic);
}
-5
View File
@@ -1,5 +0,0 @@
import { ps } from "@/lib/db/redis";
export async function GET() {
return ps.new("rubgram");
}