From 5b93130c49d95853ef0ac7a183968a9622623982 Mon Sep 17 00:00:00 2001 From: Aamir Azad Date: Mon, 24 Jun 2024 15:44:05 +0530 Subject: [PATCH] refactor: remove unnecessary code --- src/app/api/paperless/route.ts | 29 ------------------------- src/app/api/user/getUserInfo/route.ts | 24 --------------------- src/components/ui/popover.tsx | 31 --------------------------- src/server/db/schema.ts | 1 - 4 files changed, 85 deletions(-) delete mode 100644 src/app/api/paperless/route.ts delete mode 100644 src/app/api/user/getUserInfo/route.ts delete mode 100644 src/components/ui/popover.tsx diff --git a/src/app/api/paperless/route.ts b/src/app/api/paperless/route.ts deleted file mode 100644 index c41bb99..0000000 --- a/src/app/api/paperless/route.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { auth } from "@clerk/nextjs/server"; -import { type NextRequest } from 'next/server' - -export async function GET(request: NextRequest) { - const user = auth(); - - if (!user.userId) return Response.json({ error: 'Unauthorized' }, { status: 401 }); - - - const searchParams = request.nextUrl.searchParams - const query = searchParams.get("query"); - - if (!query || query == "null" || query.length < 3) return Response.json({ error: 'Bad Request' }, { status: 400 }); - - const response = await fetch( - "https://papers.aamira.me/api/search/?query=" + query, - { - method: "GET", - headers: { - "Content-Type": "application/json", - Authorization: `Token ${process.env.PAPERLESS_API_KEY}`, - }, - }, - ); - - const data = await response.json(); - - return Response.json({ data }); -} diff --git a/src/app/api/user/getUserInfo/route.ts b/src/app/api/user/getUserInfo/route.ts deleted file mode 100644 index 6c31c71..0000000 --- a/src/app/api/user/getUserInfo/route.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { db } from "@/server/db"; -import { auth } from "@clerk/nextjs/server"; -import { type NextRequest } from "next/server"; - -export async function GET(request: NextRequest) { - const user = auth(); - - if (!user.userId) - return Response.json({ error: "Unauthorized" }, { status: 401 }); - - console.log(user.userId); - - const data = await db.query.users.findFirst({ - where: (model, { eq }) => eq(model.userId, user.userId), - }); - - console.log(data); - - if (!data) { - return Response.json({ error: "Not found" }, { status: 500 }); - } - - return Response.json(data); -} diff --git a/src/components/ui/popover.tsx b/src/components/ui/popover.tsx deleted file mode 100644 index eb3e6a9..0000000 --- a/src/components/ui/popover.tsx +++ /dev/null @@ -1,31 +0,0 @@ -"use client" - -import * as React from "react" -import * as PopoverPrimitive from "@radix-ui/react-popover" - -import { cn } from "@/lib/utils" - -const Popover = PopoverPrimitive.Root - -const PopoverTrigger = PopoverPrimitive.Trigger - -const PopoverContent = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, align = "center", sideOffset = 4, ...props }, ref) => ( - - - -)) -PopoverContent.displayName = PopoverPrimitive.Content.displayName - -export { Popover, PopoverTrigger, PopoverContent } diff --git a/src/server/db/schema.ts b/src/server/db/schema.ts index 124f812..5104c6a 100644 --- a/src/server/db/schema.ts +++ b/src/server/db/schema.ts @@ -16,7 +16,6 @@ export const createTable = pgTableCreator( export const users = createTable("users", { id: serial("id").primaryKey(), userId: varchar("userId", { length: 256 }).notNull().unique(), - fullName: varchar("fullName", { length: 256 }), paperlessURL: varchar("paperlessURL", { length: 256 }), paperlessToken: varchar("paperlessToken", { length: 256 }), });