2023-03-05 15:03:20 -06:00
|
|
|
import type { NextApiRequest, NextApiResponse } from "next";
|
|
|
|
import { prisma } from "@/lib/api/db";
|
|
|
|
import { Session } from "next-auth";
|
|
|
|
|
|
|
|
export default async function (
|
|
|
|
req: NextApiRequest,
|
|
|
|
res: NextApiResponse,
|
|
|
|
session: Session
|
|
|
|
) {
|
|
|
|
const tags = await prisma.link.findMany({
|
|
|
|
where: {
|
|
|
|
collection: {
|
|
|
|
OR: [
|
|
|
|
{
|
|
|
|
ownerId: session?.user.id,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
members: {
|
|
|
|
some: {
|
|
|
|
userId: session?.user.id,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
2023-03-10 13:25:33 -06:00
|
|
|
include: {
|
|
|
|
tags: true,
|
|
|
|
collection: true,
|
|
|
|
},
|
2023-03-05 15:03:20 -06:00
|
|
|
});
|
|
|
|
|
|
|
|
return res.status(200).json({
|
|
|
|
response: tags || [],
|
|
|
|
});
|
|
|
|
}
|