aboutsummaryrefslogtreecommitdiffstats
path: root/web/app/api/v1
diff options
context:
space:
mode:
authorMohamedBassem <me@mbassem.com>2024-02-07 02:48:38 +0000
committerMohamedBassem <me@mbassem.com>2024-02-07 02:48:38 +0000
commitdaebbf0154a290fb690ed94fca23377e0f739f53 (patch)
treed02b91093a976704a558971490cf2e6406c48b94 /web/app/api/v1
parentc3ecb08ec0addfb02e2da7e79e168ca17d38cd3b (diff)
downloadkarakeep-daebbf0154a290fb690ed94fca23377e0f739f53.tar.zst
[ui] Very first draft of the link grid
Diffstat (limited to 'web/app/api/v1')
-rw-r--r--web/app/api/v1/links/route.ts36
1 files changed, 4 insertions, 32 deletions
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);