Simple, single-user event aggregation platform, for use in personal websites and other related places.
event-streaming
single-user
events
event-aggregation
1import { createMiddleware } from "hono/factory";
2import { Event } from "$lib/schemas/Event";
3
4export const endpointEventGenerator = createMiddleware(async (c, next) => {
5 const headers = c.req.header();
6 headers.Authorization = "*******";
7
8 // Don't await for performance reasons, and since we can handle missing data gracefully
9 Event.create({
10 source: "internal",
11 key: "endpoint.request.received",
12 data: {
13 path: c.req.path,
14 method: c.req.method,
15 params: c.req.param() ?? {},
16 query: c.req.query() ?? {},
17 headers: headers,
18 },
19 });
20
21 await next();
22});