Added Sharable lists

This commit is contained in:
FifthWit 2025-04-22 15:33:25 -05:00
parent d3fdf5f145
commit 3be055bb48
3 changed files with 25 additions and 0 deletions

View file

@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "lists" ADD COLUMN "public" BOOLEAN NOT NULL DEFAULT false;

View file

@ -85,6 +85,7 @@ model lists {
description String? @db.VarChar(255)
created_at DateTime @default(now()) @db.Timestamptz(0)
updated_at DateTime @updatedAt @db.Timestamptz(0)
public Boolean @default(false)
list_items list_items[]
@@index([user_id], map: "lists_user_id_index")

View file

@ -0,0 +1,22 @@
import { prisma } from "#imports";
export default defineEventHandler(async (event) => {
const id = event.context.params?.id;
const listInfo = await prisma.lists.findUnique({
where: {
id: id,
},
include: {
list_items: true,
},
});
if (!listInfo.public) {
return createError({
statusCode: 403,
message: "List is not public",
});
}
return listInfo;
})