mirror of
https://github.com/p-stream/backend.git
synced 2026-03-11 17:55:35 +00:00
Added Sharable lists
This commit is contained in:
parent
d3fdf5f145
commit
3be055bb48
3 changed files with 25 additions and 0 deletions
|
|
@ -0,0 +1,2 @@
|
|||
-- AlterTable
|
||||
ALTER TABLE "lists" ADD COLUMN "public" BOOLEAN NOT NULL DEFAULT false;
|
||||
|
|
@ -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")
|
||||
|
|
|
|||
22
server/routes/lists/[id].get.ts
Normal file
22
server/routes/lists/[id].get.ts
Normal 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;
|
||||
})
|
||||
Loading…
Reference in a new issue