el.xwx.moe/lib/api/controllers/migration/exportData.ts

27 lines
574 B
TypeScript
Raw Normal View History

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,
},
},
},
},
2024-02-23 11:11:03 -06:00
pinnedLinks: true,
whitelistedUsers: true,
},
});
if (!user) return { response: "User not found.", status: 404 };
2023-10-26 17:49:46 -05:00
const { password, id, ...userData } = user;
return { response: userData, status: 200 };
}