Skip to content

Commit cbc20f2

Browse files
fix: fixed dependancy hell
1 parent e144873 commit cbc20f2

File tree

8 files changed

+187
-161
lines changed

8 files changed

+187
-161
lines changed

package.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
"next-themes": "^0.3.0",
4545
"pdf-lib": "^1.17.1",
4646
"pdfjs-dist": "3.4.120",
47+
"prettier": "^3.5.3",
48+
"prettier-plugin-tailwindcss": "^0.6.11",
4749
"raw-loader": "^4.0.2",
4850
"react": "^18.3.1",
4951
"react-dom": "^18.3.1",
@@ -55,11 +57,11 @@
5557
"zod": "^3.24.2"
5658
},
5759
"devDependencies": {
58-
"@types/node": "22.13.10",
60+
"@types/eslint": "8.56.12",
5961
"@types/react": "^18.3.18",
6062
"@types/react-dom": "^18.3.5",
61-
"@typescript-eslint/eslint-plugin": "^7.18.0",
62-
"@typescript-eslint/parser": "^7.18.0",
63+
"@typescript-eslint/eslint-plugin": "^8.26.0",
64+
"@typescript-eslint/parser": "^8.26.0",
6365
"eslint": "^8.57.1",
6466
"eslint-config-next": "^14.2.24",
6567
"tailwindcss": "^3.4.17",

pnpm-lock.yaml

+173-149
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/api/ai-upload/route.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ async function setTagsFromCurrentLists(
257257
);
258258
const courses = data.map((course: { name: string }) => course.name);
259259
if (!courses[0] || !slots[0] || !exams[0] || !semesters[0] || !years[0]) {
260-
throw "Cannot fetch default value for courses/slot/exam/sem/year!";
260+
throw Error("Cannot fetch default value for courses/slot/exam/sem/year!");
261261
}
262262

263263
const newTags: ExamDetail = {

src/app/api/papers/route.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export async function GET(req: NextRequest) {
2121
{ status: 400 },
2222
);
2323
}
24-
console.log((await Paper.find()).map((paper)=>{paper.campus}))
24+
console.log((await Paper.find()).map((paper)=> paper.campus))
2525
const papers: IPaper[] = await Paper.find({
2626
subject: { $regex: new RegExp(`${escapedSubject}`, "i") },
2727
});

src/app/paper/[id]/page.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { extractBracketContent } from "@/util/utils";
88
import axios, { type AxiosResponse } from "axios";
99
import { type Metadata } from "next";
1010
import { redirect } from "next/navigation"; // Import redirect
11-
import QR from "@/components/qr";
1211

1312
export async function generateMetadata({
1413
params,

src/app/upload/page.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import Dropzone from "react-dropzone";
1212
import { createCanvas } from "canvas";
1313
import { getDocument, GlobalWorkerOptions } from "pdfjs-dist";
1414
import { PDFDocument } from "pdf-lib";
15-
import { ApiError } from "next/dist/server/api-utils";
1615
async function pdfToImage(file: File) {
1716
GlobalWorkerOptions.workerSrc =
1817
"https://unpkg.com/[email protected]/build/pdf.worker.min.js";
@@ -22,7 +21,7 @@ async function pdfToImage(file: File) {
2221
// Get the first page
2322
const page = pdfDoc.getPages()[0];
2423
if (!page) {
25-
throw "First page not found";
24+
throw Error("First page not found");
2625
}
2726
// Create a canvas to render the image
2827
const canvas = createCanvas(page.getWidth(), page.getHeight());

src/util/gemini.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export default async function processAndAnalyze({
3434

3535
return analysisResult[0]?.examDetail;
3636
} else {
37-
throw "Error Creating the Image";
37+
throw Error("Error Creating the Image");
3838
}
3939
}
4040
// export async function pdfToImage(file: File) {
@@ -67,7 +67,8 @@ export default async function processAndAnalyze({
6767
function parseExamDetail(analysis: string): ExamDetail {
6868
try {
6969
// Try to find JSON in the response
70-
const jsonMatch = analysis.match(/\{[\s\S]*\}/);
70+
const jsonRegex = /\{[\s\S]*\}/;
71+
const jsonMatch = jsonRegex.exec(analysis);
7172
if (jsonMatch) {
7273
const examDetail: ExamDetail = JSON.parse(jsonMatch[0]) as ExamDetail;
7374
if (examDetail.semester) {

src/util/utils.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ export function toSentenceCase(input: string): string {
1414
}
1515

1616
export function extractBracketContent(subject: string): string | null {
17-
const match = subject.match(/\[(.*?)\]/);
18-
return match?.[1] ? match[1] : "BMAT102L"; //MAKE SURE IT WORKS WHEN URL IS DONE FROM BACKEND
17+
const regex = /\[(.*?)\]/;
18+
const match = regex.exec(subject);
19+
return match?.[1] ?? "BMAT102L"; //MAKE SURE IT WORKS WHEN URL IS DONE FROM BACKEND
1920
}
2021

2122
export function extractWithoutBracketContent(subject: string): string {

0 commit comments

Comments
 (0)