From daebbf0154a290fb690ed94fca23377e0f739f53 Mon Sep 17 00:00:00 2001 From: MohamedBassem Date: Wed, 7 Feb 2024 02:48:38 +0000 Subject: [ui] Very first draft of the link grid --- web/app/api/v1/links/route.ts | 36 ++++-------------------------------- 1 file changed, 4 insertions(+), 32 deletions(-) (limited to 'web/app/api') diff --git a/web/app/api/v1/links/route.ts b/web/app/api/v1/links/route.ts index 990b6c02..87541634 100644 --- a/web/app/api/v1/links/route.ts +++ b/web/app/api/v1/links/route.ts @@ -1,6 +1,5 @@ import { authOptions } from "@/lib/auth"; -import { LinkCrawlerQueue } from "@remember/shared/queues"; -import prisma from "@remember/db"; +import { bookmarkLink, getLinks } from "@/lib/services/links"; import { zNewBookmarkedLinkRequestSchema, @@ -30,18 +29,7 @@ export async function POST(request: NextRequest) { ); } - const link = await prisma.bookmarkedLink.create({ - data: { - url: linkRequest.data.url, - userId: session.user.id, - }, - }); - - // Enqueue crawling request - await LinkCrawlerQueue.add("crawl", { - linkId: link.id, - url: link.url, - }); + const link = await bookmarkLink(linkRequest.data.url, session.user.id); let response: ZBookmarkedLink = { ...link }; return NextResponse.json(response, { status: 201 }); @@ -53,24 +41,8 @@ export async function GET() { if (!session) { return new Response(null, { status: 401 }); } - const links = await prisma.bookmarkedLink.findMany({ - where: { - userId: session.user.id, - }, - select: { - id: true, - url: true, - createdAt: true, - details: { - select: { - title: true, - description: true, - imageUrl: true, - favicon: true, - }, - }, - }, - }); + + const links = await getLinks(session.user.id); let response: ZGetLinksResponse = { links }; return NextResponse.json(response); -- cgit v1.2.3-70-g09d2