diff options
| author | MohamedBassem <me@mbassem.com> | 2024-02-06 01:17:29 +0000 |
|---|---|---|
| committer | MohamedBassem <me@mbassem.com> | 2024-02-06 01:24:38 +0000 |
| commit | e5b79e8ff0de22f86387a46c2155044adeb19fc4 (patch) | |
| tree | ecdfdc80b6121904c3aba798f683d0e8c4135028 | |
| parent | d10b76b54745eb6f4972339caa4219cb1f50ae52 (diff) | |
| download | karakeep-e5b79e8ff0de22f86387a46c2155044adeb19fc4.tar.zst | |
[API] Add the GET /api/v1/links api
| -rw-r--r-- | app/api/v1/links/route.ts | 24 |
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}); +} |
