feat: aggregate external events and improve security

- Fetch events from external ingestion service in API routes
- Decouple idempotency check from registration in Security utility
- Refine CSV storage logic to verify file content for headers
- Replace Python SDK with comprehensive, feature-rich implementation
This commit is contained in:
Team Dark Devil committed 2026-11-18 03:20:00 +06:00
1 parent 043123dc21
commit 34519c07df
13 files changed
+2099 -451

No files matched your search

+31
View File
@@ -113,6 +113,37 @@ export async function GET(request: NextRequest) {
addIfMatching({ ...event, status: "buffered" });
}
const ingestionBaseUrl = (
process.env.INGESTION_INTERNAL_URL || "http://127.0.0.1:4000"
).replace(/\/$/, "");
try {
const res = await fetch(`${ingestionBaseUrl}/internal/recent?limit=200`, {
cache: "no-store",
signal: AbortSignal.timeout(1000),
});
if (res.ok) {
const data = await res.json();
if (Array.isArray(data.events)) {
for (const evt of data.events) {
if (evt && evt.eventId) {
addIfMatching({
clientId: String(evt.clientId || ""),
eventId: String(evt.eventId),
timestamp: String(evt.timestamp || new Date().toISOString()),
payload:
typeof evt.payload === "string"
? evt.payload
: JSON.stringify(evt.payload ?? {}),
status: "buffered",
});
}
}
}
}
} catch {
// Port 4000 may not be running in isolated single-process dev mode
}
return NextResponse.json({
events: selectedRows.slice(offset),
total,