el.xwx.moe/lib/api/controllers/links/getLinks.ts

33 lines
1.1 KiB
TypeScript
Raw Normal View History

2023-04-23 08:26:39 -05:00
// Copyright (C) 2022-present Daniel31x13 <daniel31x13@gmail.com>
// This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3.
// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
2023-03-05 15:03:20 -06:00
import { prisma } from "@/lib/api/db";
2023-03-28 02:31:50 -05:00
export default async function (userId: number) {
const links = await prisma.link.findMany({
2023-03-05 15:03:20 -06:00
where: {
collection: {
OR: [
{
2023-03-28 02:31:50 -05:00
ownerId: userId,
2023-03-05 15:03:20 -06:00
},
{
members: {
some: {
2023-03-28 02:31:50 -05:00
userId,
2023-03-05 15:03:20 -06:00
},
},
},
],
},
},
2023-03-10 13:25:33 -06:00
include: {
tags: true,
collection: true,
},
2023-03-05 15:03:20 -06:00
});
2023-03-28 02:31:50 -05:00
return { response: links, status: 200 };
2023-03-05 15:03:20 -06:00
}