17 lines
546 B
TypeScript
17 lines
546 B
TypeScript
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
import { sendJson } from "../_lib/httpUtils.ts";
|
|
import { pullEvents } from "../_lib/eventRelayStore.ts";
|
|
import { buildRelayAggregate } from "../_lib/relayAggregate.ts";
|
|
|
|
export default async function handler(
|
|
req: IncomingMessage,
|
|
res: ServerResponse,
|
|
): Promise<void> {
|
|
if (req.method !== "GET") {
|
|
sendJson(res, 405, { error: "method not allowed, use GET" });
|
|
return;
|
|
}
|
|
const { entries } = pullEvents(0);
|
|
sendJson(res, 200, buildRelayAggregate(entries));
|
|
}
|