Commit 6: Adminbereich (TanStack Router, 8 Menüpunkte, Scan-Logs)

This commit is contained in:
2026-07-19 02:53:04 +02:00
parent b0ff551ca0
commit 2f31996bbb
31 changed files with 1693 additions and 112 deletions

View File

@@ -0,0 +1,52 @@
import { randomUUID } from "node:crypto";
import { desc } from "drizzle-orm";
import type { ScanLogEntry } from "@launchpad/shared";
import { db } from "../client.js";
import { scanLogs } from "../schema.js";
function mapRow(row: typeof scanLogs.$inferSelect): ScanLogEntry {
return {
id: row.id,
type: row.type as ScanLogEntry["type"],
targetId: row.targetId,
level: row.level as ScanLogEntry["level"],
message: row.message,
createdAt: row.createdAt,
};
}
export interface LogScanInput {
type: ScanLogEntry["type"];
targetId?: string | null;
level: ScanLogEntry["level"];
message: string;
}
/** Schreibt einen Eintrag für einen Scan-Versuch (Erfolg oder Fehler). */
export function logScan(input: LogScanInput): ScanLogEntry {
const id = randomUUID();
const createdAt = new Date().toISOString();
db.insert(scanLogs)
.values({
id,
type: input.type,
targetId: input.targetId ?? null,
level: input.level,
message: input.message,
createdAt,
})
.run();
return { id, type: input.type, targetId: input.targetId ?? null, level: input.level, message: input.message, createdAt };
}
export function listLogs(limit = 100): ScanLogEntry[] {
return db
.select()
.from(scanLogs)
.orderBy(desc(scanLogs.createdAt))
.limit(limit)
.all()
.map(mapRow);
}