aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorMohamedBassem <me@mbassem.com>2024-02-06 01:17:29 +0000
committerMohamedBassem <me@mbassem.com>2024-02-06 01:24:38 +0000
commite5b79e8ff0de22f86387a46c2155044adeb19fc4 (patch)
treeecdfdc80b6121904c3aba798f683d0e8c4135028 /app
parentd10b76b54745eb6f4972339caa4219cb1f50ae52 (diff)
downloadkarakeep-e5b79e8ff0de22f86387a46c2155044adeb19fc4.tar.zst
[API] Add the GET /api/v1/links api
Diffstat (limited to 'app')
-rw-r--r--app/api/v1/links/route.ts24
1 files changed, 24 insertions, 0 deletions
diff --git a/app/api/v1/links/route.ts b/app/api/v1/links/route.ts
index 9103830b..9a1de10a 100644
--- a/app/api/v1/links/route.ts
+++ b/app/api/v1/links/route.ts
@@ -26,3 +26,27 @@ export async function POST(request: NextRequest) {
return NextResponse.json(link, { status: 201 });
}
+
+export async function GET() {
+ // TODO: We probably should be using an API key here instead of the session;
+ const session = await getServerSession(authOptions);
+ if (!session) {
+ return new Response(null, { status: 401 });
+ }
+ const links = await prisma.bookmarkedLink.findMany({
+ where: {
+ userId: session.user.id,
+ },
+ include: {
+ details: {
+ select: {
+ title: true,
+ description: true,
+ imageUrl: true,
+ }
+ },
+ }
+ })
+
+ return NextResponse.json({links});
+}