pstream-backend/server/routes/users/[id]/lists/index.get.ts
2025-12-02 16:25:44 -06:00

27 lines
543 B
TypeScript

import { useAuth } from '#imports';
import { prisma } from '#imports';
export default defineEventHandler(async event => {
const userId = event.context.params?.id;
const session = await useAuth().getCurrentSession();
if (session.user !== userId) {
throw createError({
statusCode: 403,
message: 'Cannot access other user information',
});
}
const lists = await prisma.lists.findMany({
where: {
user_id: userId,
},
include: {
list_items: true,
},
});
return {
lists,
};
});