diff options
| -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}); +} |
