el.xwx.moe/lib/api/controllers/data/getData.ts
Daniel d008c441b7
Feat/import export (#136)
* added import/export functionality
2023-08-10 12:16:44 -04:00

25 lines
523 B
TypeScript

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