feat: wire convex data foundations

This commit is contained in:
2026-06-04 10:30:05 +02:00
parent df7a955736
commit 011e35cb17
62 changed files with 6335 additions and 14 deletions

36
convex/storage.ts Normal file
View File

@@ -0,0 +1,36 @@
import { v } from "convex/values";
import { mutation } from "./_generated/server";
export const generateScreenshotUploadUrl = mutation({
args: {},
returns: v.string(),
handler: async (ctx) => {
return await ctx.storage.generateUploadUrl();
},
});
export const attachScreenshot = mutation({
args: {
auditId: v.id("audits"),
storageId: v.id("_storage"),
viewport: v.union(v.literal("desktop"), v.literal("mobile")),
sourceUrl: v.string(),
capturedAt: v.number(),
width: v.number(),
height: v.number(),
mimeType: v.string(),
},
handler: async (ctx, args) => {
const audit = await ctx.db.get(args.auditId);
if (!audit) {
throw new Error("Audit not found.");
}
return await ctx.db.insert("auditScreenshots", {
...args,
createdAt: Date.now(),
});
},
});