el.xwx.moe/lib/api/controllers/public/links/linkId/getLinkById.ts

25 lines
453 B
TypeScript
Raw Normal View History

2023-11-19 07:12:37 -06:00
import { prisma } from "@/lib/api/db";
export default async function getLinkById(linkId: number) {
if (!linkId)
return {
response: "Please choose a valid link.",
status: 401,
};
const link = await prisma.link.findFirst({
where: {
id: linkId,
collection: {
isPublic: true,
},
},
include: {
tags: true,
collection: true,
},
});
return { response: link, status: 200 };
}