aboutsummaryrefslogtreecommitdiffstats
path: root/app/api
diff options
context:
space:
mode:
authorMohamedBassem <me@mbassem.com>2024-02-06 12:26:29 +0000
committerMohamedBassem <me@mbassem.com>2024-02-06 12:26:29 +0000
commit083ea5bd19172381bb53e95aaf98eaabef839c54 (patch)
tree4d1c041aab7cd8d15382330db08caeb9c5a12c63 /app/api
parentb792121977ade8bdd3fb62704b65a9fcbd1436b9 (diff)
downloadkarakeep-083ea5bd19172381bb53e95aaf98eaabef839c54.tar.zst
Move the web app into a subdir
Diffstat (limited to 'app/api')
-rw-r--r--app/api/auth/[...nextauth]/route.tsx3
-rw-r--r--app/api/v1/links/route.ts60
2 files changed, 0 insertions, 63 deletions
diff --git a/app/api/auth/[...nextauth]/route.tsx b/app/api/auth/[...nextauth]/route.tsx
deleted file mode 100644
index bfcda516..00000000
--- a/app/api/auth/[...nextauth]/route.tsx
+++ /dev/null
@@ -1,3 +0,0 @@
-import { authHandler } from "@/lib/auth";
-
-export { authHandler as GET, authHandler as POST }
diff --git a/app/api/v1/links/route.ts b/app/api/v1/links/route.ts
deleted file mode 100644
index 5be1018e..00000000
--- a/app/api/v1/links/route.ts
+++ /dev/null
@@ -1,60 +0,0 @@
-import { authOptions } from "@/lib/auth";
-import prisma from "@/lib/prisma";
-import { ZNewBookmarkedLinkRequest, ZGetLinksResponse, ZBookmarkedLink } from "@/lib/types/api/links";
-import { getServerSession } from "next-auth";
-import { NextRequest, NextResponse } from "next/server";
-
-export async function POST(request: NextRequest) {
- // 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 linkRequest = ZNewBookmarkedLinkRequest.safeParse(await request.json());
-
- if (!linkRequest.success) {
- return NextResponse.json({
- error: linkRequest.error.toString(),
- }, { status: 400 });
- }
-
- const link = await prisma.bookmarkedLink.create({
- data: {
- url: linkRequest.data.url,
- userId: session.user.id,
- }
- });
-
- let response: ZBookmarkedLink = { ...link };
-
- return NextResponse.json(response, { 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,
- },
- select: {
- id: true,
- url: true,
- createdAt: true,
- details: {
- select: {
- title: true,
- description: true,
- imageUrl: true,
- }
- },
- }
- });
-
- let response: ZGetLinksResponse = { links };
- return NextResponse.json(response);
-}