aboutsummaryrefslogtreecommitdiffstats
path: root/web/lib/services
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/lib/services
parentc3ecb08ec0addfb02e2da7e79e168ca17d38cd3b (diff)
downloadkarakeep-daebbf0154a290fb690ed94fca23377e0f739f53.tar.zst
[ui] Very first draft of the link grid
Diffstat (limited to 'web/lib/services')
-rw-r--r--web/lib/services/links.ts40
1 files changed, 40 insertions, 0 deletions
diff --git a/web/lib/services/links.ts b/web/lib/services/links.ts
new file mode 100644
index 00000000..f3ff1757
--- /dev/null
+++ b/web/lib/services/links.ts
@@ -0,0 +1,40 @@
+import { LinkCrawlerQueue } from "@remember/shared/queues";
+import prisma from "@remember/db";
+
+export async function bookmarkLink(url: string, userId: string) {
+ const link = await prisma.bookmarkedLink.create({
+ data: {
+ url,
+ userId,
+ },
+ });
+
+ // Enqueue crawling request
+ await LinkCrawlerQueue.add("crawl", {
+ linkId: link.id,
+ url: link.url,
+ });
+
+ return link;
+}
+
+export async function getLinks(userId: string) {
+ return await prisma.bookmarkedLink.findMany({
+ where: {
+ userId,
+ },
+ select: {
+ id: true,
+ url: true,
+ createdAt: true,
+ details: {
+ select: {
+ title: true,
+ description: true,
+ imageUrl: true,
+ favicon: true,
+ },
+ },
+ },
+ });
+}