Reworked access to tags as public viewer

This commit is contained in:
Oliver Schwamb
2024-07-10 10:22:58 +02:00
parent e8d0cce58a
commit abb73f80bd
7 changed files with 52 additions and 29 deletions
@@ -2,7 +2,7 @@ import { prisma } from "@/lib/api/db";
import { LinkRequestQuery, Sort } from "@/types/global";
export default async function getLink(
query: Omit<LinkRequestQuery, "tagId" | "pinnedOnly">
query: Omit<LinkRequestQuery, "tagId" | "pinnedOnly">, takeAll = false
) {
const POSTGRES_IS_ENABLED = process.env.DATABASE_URL.startsWith("postgresql");
@@ -68,7 +68,7 @@ export default async function getLink(
}
const links = await prisma.link.findMany({
take: Number(process.env.PAGINATION_TAKE_COUNT) || 20,
take: !takeAll ? Number(process.env.PAGINATION_TAKE_COUNT) || 20 : undefined,
skip: query.cursor ? 1 : undefined,
cursor: query.cursor ? { id: query.cursor } : undefined,
where: {
+1 -1
View File
@@ -1,6 +1,6 @@
import { prisma } from "@/lib/api/db";
export default async function getTags(userId: number) {
export default async function getTags(userId?: number) {
// Remove empty tags
await prisma.tag.deleteMany({
where: {