import { getCurrentUser } from "@/lib/session" import { createUploadthing, type FileRouter } from "uploadthing/next" const f = createUploadthing() export const ourFileRouter = { mediaUploader: f({ image: { maxFileSize: "4MB", maxFileCount: 4 } }) .middleware(async ({ req }) => { const user = await getCurrentUser() if (!user) throw new Error("Unauthorized") return { userId: user.id } }) .onUploadComplete(async ({ metadata, file }) => { }), imageUploader: f({ image: { maxFileSize: "4MB", maxFileCount: 1 } }) .middleware(async ({ req }) => { const user = await getCurrentUser() if (!user) throw new Error("Unauthorized") return { userId: user.id } }) .onUploadComplete(async ({ metadata, file }) => { }), bannerUploader: f({ image: { maxFileSize: "4MB", maxFileCount: 1 } }) .middleware(async ({ req }) => { const user = await getCurrentUser() if (!user) throw new Error("Unauthorized") return { userId: user.id } }) .onUploadComplete(async ({ metadata, file }) => { }), } satisfies FileRouter export type OurFileRouter = typeof ourFileRouter