gucci
This commit is contained in:
28
app/api/files/list/route.ts
Normal file
28
app/api/files/list/route.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { prisma } from "@/lib/db";
|
||||
import { getSessionUser } from "@/lib/auth";
|
||||
|
||||
export async function GET() {
|
||||
const session = await getSessionUser();
|
||||
if (!session) {
|
||||
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
||||
}
|
||||
|
||||
const files = await prisma.file.findMany({
|
||||
where: { userId: session.userId },
|
||||
orderBy: { createdAt: "desc" },
|
||||
});
|
||||
|
||||
return NextResponse.json({
|
||||
files: files.map((f) => ({
|
||||
id: f.id,
|
||||
key: f.key,
|
||||
name: f.name,
|
||||
relativePath: f.relativePath,
|
||||
contentType: f.contentType,
|
||||
sizeBytes: Number(f.sizeBytes),
|
||||
createdAt: f.createdAt,
|
||||
})),
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user