Files
buzz/lib/db/sse-endpoints.ts
T
dmgnr a83015384c
Build and Push Image / build-backend (push) Successful in 1m17s
Build and Push Image / build-frontend (push) Successful in 3m15s
Build and Push Image / push (push) Successful in 53s
feat(db): add read replicas
2026-08-30 16:19:13 +00:00

69 lines
1.7 KiB
TypeScript

import z from "zod/v4";
import type { YoutubeLiveInfo } from "@/app/api/live/route";
import { sseEndpoint, sseEndpointMap } from "./redis";
import type { auditLog, tierlistStates, TTrackingKey } from "./schema";
export const sse = sseEndpointMap({
// Artifact Admin Listener
artifact: {
update: z.object({
type: z.enum(["setLimit", "wipe", "submit", "toggleCheck", "toggleLock"]),
}),
},
// Rubgram Admin Listener
rubgram: {
update: z
.object({
type: z.enum([
"setLimit",
"wipe",
"toggleCheck",
"toggleLock",
"setFree",
"cancel",
"uploadSlip",
]),
})
.or(
z.object({
type: z.enum(["submit", "paid"]),
sub: z.string(),
}),
),
},
donate: {
ping: z.object({
id: z.string(),
name: z.string(),
amount: z.number(),
image: z.string().optional(),
message: z.string(),
}),
// roundtrip SSE system check
heartbeat: z.number(),
update: z.null(),
refresh: z.null(),
},
// Passive Update Checker
active: {
version: z.string(),
live: z.custom<YoutubeLiveInfo>(),
refresh: z.string().nullable(),
},
// Admin Live Log
log: {
update: z.custom<typeof auditLog.$inferSelect>(),
},
slip_sync: {
complete: z.custom<TTrackingKey>(),
connected: z.custom<TTrackingKey>(),
},
});
export const adminSseList: (keyof typeof sse)[] = ["log"];
export function tlSse<T extends string>(list: T) {
return sseEndpoint(`tl.${list}`, {
update_states: z.custom<(typeof tierlistStates.$inferSelect)[]>(),
update_placements: z.record(z.string(), z.string().array()),
});
}