el.xwx.moe/lib/api/controllers/migration/exportData.ts
daniel31x13 1260e8c093 fixes
2024-08-18 16:39:43 -04:00

27 lines
574 B
TypeScript

import { prisma } from "@/lib/api/db";
export default async function exportData(userId: number) {
const user = await prisma.user.findUnique({
where: { id: userId },
include: {
collections: {
include: {
links: {
include: {
tags: true,
},
},
},
},
pinnedLinks: true,
whitelistedUsers: true,
},
});
if (!user) return { response: "User not found.", status: 404 };
const { password, id, ...userData } = user;
return { response: userData, status: 200 };
}