├── backend ├── .gitignore ├── package-lock.json ├── package.json ├── prisma │ ├── migrations │ │ ├── 20250419154341_usermodel_added │ │ │ └── migration.sql │ │ ├── 20250419164220_problem_model_is_added │ │ │ └── migration.sql │ │ ├── 20250427165156_added_submission_testcases_problemsolved │ │ │ └── migration.sql │ │ ├── 20250504151141_playlist_schema_is_added │ │ │ └── migration.sql │ │ └── migration_lock.toml │ └── schema.prisma ├── problem.json ├── sample.json ├── src │ ├── controllers │ │ ├── auth.controller.js │ │ ├── executeCode.controller.js │ │ ├── playlist.controller.js │ │ ├── problem.controller.js │ │ └── submission.controller.js │ ├── generated │ │ └── prisma │ │ │ ├── client.d.ts │ │ │ ├── client.js │ │ │ ├── default.d.ts │ │ │ ├── default.js │ │ │ ├── edge.d.ts │ │ │ ├── edge.js │ │ │ ├── index-browser.js │ │ │ ├── index.d.ts │ │ │ ├── index.js │ │ │ ├── package.json │ │ │ ├── query_engine-windows.dll.node │ │ │ ├── runtime │ │ │ ├── edge-esm.js │ │ │ ├── edge.js │ │ │ ├── index-browser.d.ts │ │ │ ├── index-browser.js │ │ │ ├── library.d.ts │ │ │ ├── library.js │ │ │ ├── react-native.js │ │ │ └── wasm.js │ │ │ ├── schema.prisma │ │ │ ├── wasm.d.ts │ │ │ └── wasm.js │ ├── index.js │ ├── libs │ │ ├── db.js │ │ └── judge0.lib.js │ ├── middleware │ │ └── auth.middleware.js │ └── routes │ │ ├── auth.routes.js │ │ ├── executeCode.routes.js │ │ ├── playlist.routes.js │ │ ├── problem.routes.js │ │ └── submission.routes.js └── test.js ├── frontend ├── .gitignore ├── README.md ├── eslint.config.js ├── index.html ├── package-lock.json ├── package.json ├── public │ ├── leetlab.svg │ └── vite.svg ├── src │ ├── App.jsx │ ├── assets │ │ └── react.svg │ ├── components │ │ ├── AddToPlaylist.jsx │ │ ├── AdminRoute.jsx │ │ ├── AuthImagePattern.jsx │ │ ├── CreatePlaylistModal.jsx │ │ ├── CreateProblemForm.jsx │ │ ├── LogoutButton.jsx │ │ ├── Navbar.jsx │ │ ├── ProblemTable.jsx │ │ ├── Submission.jsx │ │ └── SubmissionList.jsx │ ├── index.css │ ├── layout │ │ └── Layout.jsx │ ├── lib │ │ ├── axios.js │ │ └── lang.js │ ├── main.jsx │ ├── page │ │ ├── AddProblem.jsx │ │ ├── HomePage.jsx │ │ ├── LoginPage.jsx │ │ ├── ProblemPage.jsx │ │ └── SignUpPage.jsx │ └── store │ │ ├── useAction.js │ │ ├── useAuthStore.js │ │ ├── useExecutionStore.js │ │ ├── usePlaylistStore.js │ │ ├── useProblemStore.js │ │ └── useSubmissionStore.js └── vite.config.js └── notes.md /backend/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | # Keep environment variables out of version control 3 | .env 4 | -------------------------------------------------------------------------------- /backend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "backend", 3 | "version": "1.0.0", 4 | "main": "src/index.js", 5 | "scripts": { 6 | "dev": "nodemon src/index.js" 7 | }, 8 | "keywords": [], 9 | "author": "", 10 | "license": "ISC", 11 | "type": "module", 12 | "description": "", 13 | "dependencies": { 14 | "@prisma/client": "^6.6.0", 15 | "axios": "^1.9.0", 16 | "bcryptjs": "^3.0.2", 17 | "cookie-parser": "^1.4.7", 18 | "cors": "^2.8.5", 19 | "dotenv": "^16.5.0", 20 | "express": "^5.1.0", 21 | "jsonwebtoken": "^9.0.2", 22 | "prisma": "^6.6.0" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /backend/prisma/migrations/20250419154341_usermodel_added/migration.sql: -------------------------------------------------------------------------------- 1 | -- CreateEnum 2 | CREATE TYPE "UserRole" AS ENUM ('ADMIN', 'USER'); 3 | 4 | -- CreateTable 5 | CREATE TABLE "User" ( 6 | "id" TEXT NOT NULL, 7 | "name" TEXT, 8 | "email" TEXT NOT NULL, 9 | "image" TEXT, 10 | "role" "UserRole" NOT NULL DEFAULT 'USER', 11 | "password" TEXT NOT NULL, 12 | "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, 13 | "updatedAt" TIMESTAMP(3) NOT NULL, 14 | 15 | CONSTRAINT "User_pkey" PRIMARY KEY ("id") 16 | ); 17 | 18 | -- CreateIndex 19 | CREATE UNIQUE INDEX "User_email_key" ON "User"("email"); 20 | -------------------------------------------------------------------------------- /backend/prisma/migrations/20250419164220_problem_model_is_added/migration.sql: -------------------------------------------------------------------------------- 1 | -- CreateEnum 2 | CREATE TYPE "Difficulty" AS ENUM ('EASY', 'MEDIUM', 'HARD'); 3 | 4 | -- CreateTable 5 | CREATE TABLE "Problem" ( 6 | "id" TEXT NOT NULL, 7 | "title" TEXT NOT NULL, 8 | "description" TEXT NOT NULL, 9 | "difficulty" "Difficulty" NOT NULL, 10 | "tags" TEXT[], 11 | "userId" TEXT NOT NULL, 12 | "examples" JSONB NOT NULL, 13 | "constraints" TEXT NOT NULL, 14 | "hints" TEXT, 15 | "editorial" TEXT, 16 | "testcases" JSONB NOT NULL, 17 | "codeSnippets" JSONB NOT NULL, 18 | "referenceSolutions" JSONB NOT NULL, 19 | "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, 20 | "updatedAt" TIMESTAMP(3) NOT NULL, 21 | 22 | CONSTRAINT "Problem_pkey" PRIMARY KEY ("id") 23 | ); 24 | 25 | -- AddForeignKey 26 | ALTER TABLE "Problem" ADD CONSTRAINT "Problem_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; 27 | -------------------------------------------------------------------------------- /backend/prisma/migrations/20250427165156_added_submission_testcases_problemsolved/migration.sql: -------------------------------------------------------------------------------- 1 | -- CreateTable 2 | CREATE TABLE "Submission" ( 3 | "id" TEXT NOT NULL, 4 | "userId" TEXT NOT NULL, 5 | "problemId" TEXT NOT NULL, 6 | "sourceCode" JSONB NOT NULL, 7 | "language" TEXT NOT NULL, 8 | "stdin" TEXT, 9 | "stdout" TEXT, 10 | "stderr" TEXT, 11 | "compileOutput" TEXT, 12 | "status" TEXT NOT NULL, 13 | "memory" TEXT, 14 | "time" TEXT, 15 | "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, 16 | "updatedAt" TIMESTAMP(3) NOT NULL, 17 | 18 | CONSTRAINT "Submission_pkey" PRIMARY KEY ("id") 19 | ); 20 | 21 | -- CreateTable 22 | CREATE TABLE "TestCaseResult" ( 23 | "id" TEXT NOT NULL, 24 | "submissionId" TEXT NOT NULL, 25 | "testCase" INTEGER NOT NULL, 26 | "passed" BOOLEAN NOT NULL, 27 | "stdout" TEXT, 28 | "expected" TEXT NOT NULL, 29 | "stderr" TEXT, 30 | "compileOutput" TEXT, 31 | "status" TEXT NOT NULL, 32 | "memory" TEXT, 33 | "time" TEXT, 34 | "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, 35 | "updatedAt" TIMESTAMP(3) NOT NULL, 36 | 37 | CONSTRAINT "TestCaseResult_pkey" PRIMARY KEY ("id") 38 | ); 39 | 40 | -- CreateTable 41 | CREATE TABLE "ProblemSolved" ( 42 | "id" TEXT NOT NULL, 43 | "userId" TEXT NOT NULL, 44 | "problemId" TEXT NOT NULL, 45 | "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, 46 | "updatedAt" TIMESTAMP(3) NOT NULL, 47 | 48 | CONSTRAINT "ProblemSolved_pkey" PRIMARY KEY ("id") 49 | ); 50 | 51 | -- CreateIndex 52 | CREATE INDEX "TestCaseResult_submissionId_idx" ON "TestCaseResult"("submissionId"); 53 | 54 | -- CreateIndex 55 | CREATE UNIQUE INDEX "ProblemSolved_userId_problemId_key" ON "ProblemSolved"("userId", "problemId"); 56 | 57 | -- AddForeignKey 58 | ALTER TABLE "Submission" ADD CONSTRAINT "Submission_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; 59 | 60 | -- AddForeignKey 61 | ALTER TABLE "Submission" ADD CONSTRAINT "Submission_problemId_fkey" FOREIGN KEY ("problemId") REFERENCES "Problem"("id") ON DELETE CASCADE ON UPDATE CASCADE; 62 | 63 | -- AddForeignKey 64 | ALTER TABLE "TestCaseResult" ADD CONSTRAINT "TestCaseResult_submissionId_fkey" FOREIGN KEY ("submissionId") REFERENCES "Submission"("id") ON DELETE CASCADE ON UPDATE CASCADE; 65 | 66 | -- AddForeignKey 67 | ALTER TABLE "ProblemSolved" ADD CONSTRAINT "ProblemSolved_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; 68 | 69 | -- AddForeignKey 70 | ALTER TABLE "ProblemSolved" ADD CONSTRAINT "ProblemSolved_problemId_fkey" FOREIGN KEY ("problemId") REFERENCES "Problem"("id") ON DELETE CASCADE ON UPDATE CASCADE; 71 | -------------------------------------------------------------------------------- /backend/prisma/migrations/20250504151141_playlist_schema_is_added/migration.sql: -------------------------------------------------------------------------------- 1 | -- CreateTable 2 | CREATE TABLE "Playlist" ( 3 | "id" TEXT NOT NULL, 4 | "name" TEXT NOT NULL, 5 | "description" TEXT, 6 | "userId" TEXT NOT NULL, 7 | "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, 8 | "updatedAt" TIMESTAMP(3) NOT NULL, 9 | 10 | CONSTRAINT "Playlist_pkey" PRIMARY KEY ("id") 11 | ); 12 | 13 | -- CreateTable 14 | CREATE TABLE "ProblemInPlaylist" ( 15 | "id" TEXT NOT NULL, 16 | "playListId" TEXT NOT NULL, 17 | "problemId" TEXT NOT NULL, 18 | "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, 19 | "updatedAt" TIMESTAMP(3) NOT NULL, 20 | 21 | CONSTRAINT "ProblemInPlaylist_pkey" PRIMARY KEY ("id") 22 | ); 23 | 24 | -- CreateIndex 25 | CREATE UNIQUE INDEX "Playlist_name_userId_key" ON "Playlist"("name", "userId"); 26 | 27 | -- CreateIndex 28 | CREATE UNIQUE INDEX "ProblemInPlaylist_playListId_problemId_key" ON "ProblemInPlaylist"("playListId", "problemId"); 29 | 30 | -- AddForeignKey 31 | ALTER TABLE "Playlist" ADD CONSTRAINT "Playlist_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; 32 | 33 | -- AddForeignKey 34 | ALTER TABLE "ProblemInPlaylist" ADD CONSTRAINT "ProblemInPlaylist_playListId_fkey" FOREIGN KEY ("playListId") REFERENCES "Playlist"("id") ON DELETE CASCADE ON UPDATE CASCADE; 35 | 36 | -- AddForeignKey 37 | ALTER TABLE "ProblemInPlaylist" ADD CONSTRAINT "ProblemInPlaylist_problemId_fkey" FOREIGN KEY ("problemId") REFERENCES "Problem"("id") ON DELETE CASCADE ON UPDATE CASCADE; 38 | -------------------------------------------------------------------------------- /backend/prisma/migrations/migration_lock.toml: -------------------------------------------------------------------------------- 1 | # Please do not edit this file manually 2 | # It should be added in your version-control system (e.g., Git) 3 | provider = "postgresql" 4 | -------------------------------------------------------------------------------- /backend/prisma/schema.prisma: -------------------------------------------------------------------------------- 1 | // This is your Prisma schema file, 2 | // learn more about it in the docs: https://pris.ly/d/prisma-schema 3 | 4 | // Looking for ways to speed up your queries, or scale easily with your serverless or edge functions? 5 | // Try Prisma Accelerate: https://pris.ly/cli/accelerate-init 6 | 7 | generator client { 8 | provider = "prisma-client-js" 9 | output = "../src/generated/prisma" 10 | } 11 | 12 | datasource db { 13 | provider = "postgresql" 14 | url = env("DATABASE_URL") 15 | } 16 | 17 | enum UserRole { 18 | ADMIN 19 | USER 20 | } 21 | 22 | enum Difficulty { 23 | EASY 24 | MEDIUM 25 | HARD 26 | } 27 | 28 | model User { 29 | id String @id @default(uuid()) 30 | name String? 31 | email String @unique 32 | image String? 33 | role UserRole @default(USER) 34 | password String 35 | createdAt DateTime @default(now()) 36 | updatedAt DateTime @updatedAt 37 | 38 | problems Problem[] 39 | submission Submission[] 40 | problemSolved ProblemSolved[] 41 | playlists Playlist[] 42 | } 43 | 44 | model Problem { 45 | id String @id @default(uuid()) 46 | title String 47 | description String 48 | difficulty Difficulty 49 | tags String[] // ["tag1", "tag2", "tag3"] 50 | userId String 51 | examples Json 52 | constraints String 53 | hints String? 54 | editorial String? 55 | 56 | testcases Json // 57 | codeSnippets Json 58 | referenceSolutions Json 59 | 60 | createdAt DateTime @default(now()) 61 | updatedAt DateTime @updatedAt 62 | 63 | // Relationship 64 | user User @relation(fields: [userId], references: [id], onDelete: Cascade) 65 | submission Submission[] 66 | solvedBy ProblemSolved[] 67 | problemsPlaylists ProblemInPlaylist[] 68 | 69 | } 70 | // enum Status{ 71 | // ACCEPTED 72 | // WORNG_ANSWER 73 | // } 74 | 75 | model Submission { 76 | id String @id @default(uuid()) 77 | userId String 78 | problemId String 79 | sourceCode Json 80 | language String 81 | stdin String? 82 | stdout String? 83 | stderr String? 84 | compileOutput String? 85 | status String // Accepted , wrong answer 86 | memory String? 87 | time String? 88 | 89 | createdAt DateTime @default(now()) 90 | updatedAt DateTime @updatedAt 91 | 92 | user User @relation(fields: [userId], references: [id], onDelete: Cascade) 93 | problem Problem @relation(fields: [problemId], references: [id], onDelete: Cascade) 94 | 95 | testCases TestCaseResult[] 96 | } 97 | 98 | model TestCaseResult { 99 | id String @id @default(uuid()) 100 | submissionId String 101 | testCase Int 102 | passed Boolean 103 | stdout String? 104 | expected String 105 | stderr String? 106 | compileOutput String? 107 | status String 108 | memory String? 109 | time String? 110 | 111 | createdAt DateTime @default(now()) 112 | updatedAt DateTime @updatedAt 113 | 114 | submission Submission @relation(fields: [submissionId], references: [id], onDelete: Cascade) 115 | 116 | @@index([submissionId]) 117 | } 118 | 119 | model ProblemSolved { 120 | id String @id @default(uuid()) 121 | userId String 122 | problemId String 123 | createdAt DateTime @default(now()) 124 | updatedAt DateTime @updatedAt 125 | 126 | user User @relation(fields: [userId], references: [id], onDelete: Cascade) 127 | problem Problem @relation(fields: [problemId], references: [id], onDelete: Cascade) 128 | 129 | @@unique([userId, problemId]) 130 | } 131 | 132 | 133 | model Playlist{ 134 | id String @id @default(uuid()) 135 | name String 136 | description String? 137 | userId String 138 | 139 | createdAt DateTime @default(now()) 140 | updatedAt DateTime @updatedAt 141 | 142 | problems ProblemInPlaylist[] 143 | 144 | user User @relation(fields: [userId], references: [id], onDelete: Cascade) 145 | 146 | @@unique([name , userId]) // unique playlist names per user 147 | } 148 | 149 | 150 | model ProblemInPlaylist{ 151 | id String @id @default(uuid()) 152 | playListId String 153 | problemId String 154 | createdAt DateTime @default(now()) 155 | updatedAt DateTime @updatedAt 156 | 157 | playlist Playlist @relation(fields: [playListId] , references: [id] , onDelete: Cascade) 158 | problem Problem @relation(fields: [problemId] , references: [id] , onDelete: Cascade) 159 | 160 | @@unique([playListId , problemId]) 161 | 162 | } -------------------------------------------------------------------------------- /backend/problem.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aestheticsuraj234/leetlab/6f62504d449bcf691bb22da52e1fc50180c703ab/backend/problem.json -------------------------------------------------------------------------------- /backend/sample.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Add Two Numbers", 3 | "description": "Given two numbers a and b add them up and return the outout", 4 | "difficulty": "EASY", 5 | "tags": [ 6 | "math", 7 | "operators", 8 | "addition" 9 | ], 10 | "examples": { 11 | "PYTHON": { 12 | "input": "3 7", 13 | "output": "10", 14 | "explanation": "Adding 3 and 7 gives 10." 15 | }, 16 | "JAVASCRIPT": { 17 | "input": "-5 12", 18 | "output": "7", 19 | "explanation": "Adding -5 and 12 gives 7." 20 | } 21 | }, 22 | "constraints": "-10^9 ≤ a, b ≤ 10^9", 23 | "testcases": [ 24 | { 25 | "input": "100 200", 26 | "output": "300" 27 | }, 28 | { 29 | "input": "-500 -600", 30 | "output": "-1100" 31 | }, 32 | { 33 | "input": "0 0", 34 | "output": "0" 35 | } 36 | ], 37 | "codeSnippets": { 38 | "JAVASCRIPT": "const fs = require('fs');\n\nfunction addTwoNumbers(a, b) {\n // Write your code here\n // Return the sum of a and b\n return a + b;\n}\n\n// Reading input from stdin (using fs to read all input)\nconst input = fs.readFileSync(0, 'utf-8').trim();\nconst [a, b] = input.split(' ').map(Number);\n\nconsole.log(addTwoNumbers(a, b));", 39 | "PYTHON": "def add_two_numbers(a, b):\n # Write your code here\n # Return the sum of a and b\n return a + b\n\nimport sys\ninput_line = sys.stdin.read()\na, b = map(int, input_line.split())\nprint(add_two_numbers(a, b))", 40 | "JAVA": "import java.util.Scanner;\n\npublic class Main {\n public static int addTwoNumbers(int a, int b) {\n // Write your code here\n // Return the sum of a and b\n return a + b;\n }\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int a = sc.nextInt();\n int b = sc.nextInt();\n System.out.println(addTwoNumbers(a, b));\n }\n}" 41 | }, 42 | "referenceSolutions": { 43 | "JAVASCRIPT": "const fs = require('fs');\n\n// Reading input from stdin (using fs to read all input)\nconst input = fs.readFileSync(0, 'utf-8').trim();\nconst [a, b] = input.split(' ').map(Number);\n\nconsole.log(a + b);", 44 | "PYTHON": "import sys\ninput_line = sys.stdin.read()\na, b = map(int, input_line.split())\nprint(a + b)", 45 | "JAVA": "import java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int a = sc.nextInt();\n int b = sc.nextInt();\n System.out.println(a + b);\n }\n}" 46 | } 47 | } -------------------------------------------------------------------------------- /backend/src/controllers/auth.controller.js: -------------------------------------------------------------------------------- 1 | import bcrypt from "bcryptjs"; 2 | import {db} from "../libs/db.js" 3 | import { UserRole } from "../generated/prisma/index.js"; 4 | import jwt from "jsonwebtoken"; 5 | 6 | export const register = async (req , res)=>{ 7 | const {email , password , name} = req.body; 8 | 9 | try { 10 | const existingUser = await db.user.findUnique({ 11 | where:{ 12 | email 13 | } 14 | }) 15 | 16 | if(existingUser){ 17 | return res.status(400).json({ 18 | error:"User already exists" 19 | }) 20 | } 21 | 22 | 23 | const hashedPassword = await bcrypt.hash(password , 10); 24 | 25 | const newUser = await db.user.create({ 26 | data:{ 27 | email, 28 | password:hashedPassword, 29 | name, 30 | role:UserRole.USER 31 | } 32 | }) 33 | 34 | const token = jwt.sign({id:newUser.id} , process.env.JWT_SECRET , { 35 | expiresIn:"7d" 36 | }) 37 | 38 | res.cookie("jwt" , token , { 39 | httpOnly:true, 40 | sameSite:"strict", 41 | secure:process.env.NODE_ENV !== "development", 42 | maxAge:1000 * 60 * 60 * 24 * 7 // 7 days 43 | }) 44 | 45 | res.status(201).json({ 46 | success:true, 47 | message:"User created successfully", 48 | user:{ 49 | id:newUser.id, 50 | email:newUser.email, 51 | name:newUser.name, 52 | role:newUser.role, 53 | image:newUser.image 54 | } 55 | }) 56 | 57 | } catch (error) { 58 | console.error("Error creating user:", error); 59 | res.status(500).json({ 60 | error:"Error creating user" 61 | }) 62 | } 63 | } 64 | 65 | export const login = async (req , res)=>{ 66 | const {email , password} = req.body; 67 | 68 | try { 69 | const user = await db.user.findUnique({ 70 | where:{ 71 | email 72 | } 73 | }) 74 | 75 | if(!user){ 76 | return res.status(401).json({ 77 | error:"User not found" 78 | }) 79 | } 80 | 81 | const isMatch = await bcrypt.compare(password , user.password); 82 | 83 | if(!isMatch){ 84 | return res.status(401).json({ 85 | error:"Invalid credentials" 86 | }) 87 | } 88 | 89 | const token = jwt.sign({id:user.id} , process.env.JWT_SECRET,{ 90 | expiresIn:"7d" 91 | }) 92 | 93 | res.cookie("jwt" , token , { 94 | httpOnly:true, 95 | sameSite:"strict", 96 | secure:process.env.NODE_ENV !== "development", 97 | maxAge:1000 * 60 * 60 * 24 * 7 // 7 days 98 | }) 99 | 100 | res.status(200).json({ 101 | success:true, 102 | message:"User Logged in successfully", 103 | user:{ 104 | id:user.id, 105 | email:user.email, 106 | name:user.name, 107 | role:user.role, 108 | image:user.image 109 | } 110 | }) 111 | 112 | 113 | } catch (error) { 114 | console.error("Error creating user:", error); 115 | res.status(500).json({ 116 | error:"Error logging in user" 117 | }) 118 | } 119 | } 120 | 121 | 122 | export const logout = async (req , res)=>{ 123 | try { 124 | res.clearCookie("jwt" , { 125 | httpOnly:true, 126 | sameSite:"strict", 127 | secure:process.env.NODE_ENV !== "development", 128 | }) 129 | 130 | res.status(200).json({ 131 | success:true, 132 | message:"User logged out successfully" 133 | }) 134 | } catch (error) { 135 | console.error("Error logging out user:", error); 136 | res.status(500).json({ 137 | error:"Error logging out user" 138 | }) 139 | } 140 | } 141 | 142 | export const check = async (req , res)=>{ 143 | try { 144 | res.status(200).json({ 145 | success:true, 146 | message:"User authenticated successfully", 147 | user:req.user 148 | }); 149 | } catch (error) { 150 | console.error("Error checking user:", error); 151 | res.status(500).json({ 152 | error:"Error checking user" 153 | }) 154 | } 155 | } -------------------------------------------------------------------------------- /backend/src/controllers/executeCode.controller.js: -------------------------------------------------------------------------------- 1 | import { db } from "../libs/db.js"; 2 | import { 3 | getLanguageName, 4 | pollBatchResults, 5 | submitBatch, 6 | } from "../libs/judge0.lib.js"; 7 | 8 | export const executeCode = async (req, res) => { 9 | try { 10 | const { source_code, language_id, stdin, expected_outputs, problemId } = 11 | req.body; 12 | 13 | const userId = req.user.id; 14 | 15 | // Validate test cases 16 | 17 | if ( 18 | !Array.isArray(stdin) || 19 | stdin.length === 0 || 20 | !Array.isArray(expected_outputs) || 21 | expected_outputs.length !== stdin.length 22 | ) { 23 | return res.status(400).json({ error: "Invalid or Missing test cases" }); 24 | } 25 | 26 | // 2. Prepare each test cases for judge0 batch submission 27 | const submissions = stdin.map((input) => ({ 28 | source_code, 29 | language_id, 30 | stdin: input, 31 | })); 32 | 33 | // 3. Send batch of submissions to judge0 34 | const submitResponse = await submitBatch(submissions); 35 | 36 | const tokens = submitResponse.map((res) => res.token); 37 | 38 | // 4. Poll judge0 for results of all submitted test cases 39 | const results = await pollBatchResults(tokens); 40 | 41 | console.log("Result-------------"); 42 | console.log(results); 43 | 44 | // Analyze test case results 45 | let allPassed = true; 46 | const detailedResults = results.map((result, i) => { 47 | const stdout = result.stdout?.trim(); 48 | const expected_output = expected_outputs[i]?.trim(); 49 | const passed = stdout === expected_output; 50 | 51 | if (!passed) allPassed = false; 52 | 53 | return { 54 | testCase: i + 1, 55 | passed, 56 | stdout, 57 | expected: expected_output, 58 | stderr: result.stderr || null, 59 | compile_output: result.compile_output || null, 60 | status: result.status.description, 61 | memory: result.memory ? `${result.memory} KB` : undefined, 62 | time: result.time ? `${result.time} s` : undefined, 63 | }; 64 | 65 | // console.log(`Testcase #${i+1}`); 66 | // console.log(`Input for testcase #${i+1}: ${stdin[i]}`) 67 | // console.log(`Expected Output for testcase #${i+1}: ${expected_output}`) 68 | // console.log(`Actual output for testcase #${i+1}: ${stdout}`) 69 | 70 | // console.log(`Matched testcase #${i+1}: ${passed}`) 71 | }); 72 | 73 | console.log(detailedResults); 74 | 75 | // store submission summary 76 | const submission = await db.submission.create({ 77 | data: { 78 | userId, 79 | problemId, 80 | sourceCode: source_code, 81 | language: getLanguageName(language_id), 82 | stdin: stdin.join("\n"), 83 | stdout: JSON.stringify(detailedResults.map((r) => r.stdout)), 84 | stderr: detailedResults.some((r) => r.stderr) 85 | ? JSON.stringify(detailedResults.map((r) => r.stderr)) 86 | : null, 87 | compileOutput: detailedResults.some((r) => r.compile_output) 88 | ? JSON.stringify(detailedResults.map((r) => r.compile_output)) 89 | : null, 90 | status: allPassed ? "Accepted" : "Wrong Answer", 91 | memory: detailedResults.some((r) => r.memory) 92 | ? JSON.stringify(detailedResults.map((r) => r.memory)) 93 | : null, 94 | time: detailedResults.some((r) => r.time) 95 | ? JSON.stringify(detailedResults.map((r) => r.time)) 96 | : null, 97 | }, 98 | }); 99 | 100 | // If All passed = true mark problem as solved for the current user 101 | if (allPassed) { 102 | await db.problemSolved.upsert({ 103 | where: { 104 | userId_problemId: { 105 | userId, 106 | problemId, 107 | }, 108 | }, 109 | update: {}, 110 | create: { 111 | userId, 112 | problemId, 113 | }, 114 | }); 115 | } 116 | // 8. Save individual test case results using detailedResult 117 | 118 | const testCaseResults = detailedResults.map((result) => ({ 119 | submissionId: submission.id, 120 | testCase: result.testCase, 121 | passed: result.passed, 122 | stdout: result.stdout, 123 | expected: result.expected, 124 | stderr: result.stderr, 125 | compileOutput: result.compile_output, 126 | status: result.status, 127 | memory: result.memory, 128 | time: result.time, 129 | })); 130 | 131 | await db.testCaseResult.createMany({ 132 | data: testCaseResults, 133 | }); 134 | 135 | const submissionWithTestCase = await db.submission.findUnique({ 136 | where: { 137 | id: submission.id, 138 | }, 139 | include: { 140 | testCases: true, 141 | }, 142 | }); 143 | // 144 | res.status(200).json({ 145 | success: true, 146 | message: "Code Executed! Successfully!", 147 | submission: submissionWithTestCase, 148 | }); 149 | } catch (error) { 150 | console.error("Error executing code:", error.message); 151 | res.status(500).json({ error: "Failed to execute code" }); 152 | } 153 | }; 154 | -------------------------------------------------------------------------------- /backend/src/controllers/playlist.controller.js: -------------------------------------------------------------------------------- 1 | import { db } from "../libs/db.js"; 2 | 3 | export const createPlayList = async (req, res) => { 4 | try { 5 | const { name, description } = req.body; 6 | const userId = req.user.id; 7 | 8 | const playList = await db.playlist.create({ 9 | data: { 10 | name, 11 | description, 12 | userId, 13 | }, 14 | }); 15 | res.status(200).json({ 16 | success: true, 17 | message: "Playlist created successfully", 18 | playList, 19 | }); 20 | } catch (error) { 21 | console.error("Error creating playlist:", error); 22 | res.status(500).json({ error: "Failed to create playlist" }); 23 | } 24 | }; 25 | 26 | export const getPlayAllListDetails = async (req, res) => { 27 | try { 28 | const playLists = await db.playlist.findMany({ 29 | where: { 30 | userId: req.user.id, 31 | }, 32 | include: { 33 | problems: { 34 | include: { 35 | problem: true, 36 | }, 37 | }, 38 | }, 39 | }); 40 | res.status(200).json({ 41 | success: true, 42 | message: "Playlist fetched successfully", 43 | playLists, 44 | }); 45 | } catch (error) { 46 | console.error("Error fetching playlist:", error); 47 | res.status(500).json({ error: "Failed to fetch playlist" }); 48 | } 49 | }; 50 | export const getPlayListDetails = async (req, res) => { 51 | const { playlistId } = req.params; 52 | 53 | try { 54 | const playList = await db.playlist.findUnique({ 55 | where: { id: playlistId, userId: req.user.id }, 56 | include: { 57 | problems: { 58 | include: { 59 | problem: true, 60 | }, 61 | }, 62 | }, 63 | }); 64 | 65 | if (!playList) { 66 | return res.status(404).json({ error: "Playlist not found" }); 67 | } 68 | 69 | res.status(200).json({ 70 | success: true, 71 | message: "Playlist fetched successfully", 72 | playList, 73 | }); 74 | } catch (error) { 75 | console.error("Error fetching playlist:", error); 76 | res.status(500).json({ error: "Failed to fetch playlist" }); 77 | } 78 | }; 79 | 80 | export const addProblemToPlaylist = async (req, res) => { 81 | const { playlistId } = req.params; 82 | const { problemIds } = req.body; // Accept an array of problem IDs 83 | 84 | try { 85 | // Ensure problemIds is an array 86 | if (!Array.isArray(problemIds) || problemIds.length === 0) { 87 | return res.status(400).json({ error: "Invalid or missing problemIds" }); 88 | } 89 | 90 | console.log( 91 | problemIds.map((problemId) => ({ 92 | playlistId, 93 | problemId, 94 | })) 95 | ); 96 | 97 | // Create records for each problem in the playlist 98 | const problemsInPlaylist = await db.problemInPlaylist.createMany({ 99 | data: problemIds.map((problemId) => ({ 100 | playListId: playlistId, // ✅ match your Prisma field name exactly 101 | problemId, 102 | })), 103 | }); 104 | 105 | res.status(201).json({ 106 | success: true, 107 | message: "Problems added to playlist successfully", 108 | problemsInPlaylist, 109 | }); 110 | } catch (error) { 111 | console.error("Error adding problems to playlist:", error.message); 112 | res.status(500).json({ error: "Failed to add problems to playlist" }); 113 | } 114 | }; 115 | 116 | export const deletePlayList = async (req, res) => { 117 | const { playlistId } = req.params; 118 | 119 | try { 120 | const deletedPlaylist = await db.playlist.delete({ 121 | where: { 122 | id: playlistId, 123 | }, 124 | }); 125 | 126 | res.status(200).json({ 127 | success: true, 128 | message: "Playlist deleted successfully", 129 | deletedPlaylist, 130 | }); 131 | } catch (error) { 132 | console.error("Error deleting playlist:", error.message); 133 | res.status(500).json({ error: "Failed to delete playlist" }); 134 | } 135 | }; 136 | 137 | export const removeProblemFromPlaylist = async (req, res) => { 138 | const { playlistId } = req.params; 139 | const { problemIds } = req.body; 140 | 141 | try { 142 | if (!Array.isArray(problemIds) || problemIds.length === 0) { 143 | return res.status(400).json({ error: "Invalid or missing problemIds" }); 144 | } 145 | // Only delete given problemIds not all 146 | 147 | const deletedProblem = await db.problemInPlaylist.deleteMany({ 148 | where: { 149 | playlistId, 150 | problemId: { 151 | in: problemIds, 152 | }, 153 | }, 154 | }); 155 | 156 | res.status(200).json({ 157 | success: true, 158 | message: "Problem removed from playlist successfully", 159 | deletedProblem, 160 | }); 161 | } catch (error) { 162 | console.error("Error removing problem from playlist:", error.message); 163 | res.status(500).json({ error: "Failed to remove problem from playlist" }); 164 | } 165 | }; 166 | -------------------------------------------------------------------------------- /backend/src/controllers/problem.controller.js: -------------------------------------------------------------------------------- 1 | import { db } from "../libs/db.js"; 2 | import { 3 | getJudge0LanguageId, 4 | pollBatchResults, 5 | submitBatch, 6 | } from "../libs/judge0.lib.js"; 7 | 8 | export const createProblem = async (req, res) => { 9 | const { 10 | title, 11 | description, 12 | difficulty, 13 | tags, 14 | examples, 15 | constraints, 16 | testcases, 17 | codeSnippets, 18 | referenceSolutions, 19 | } = req.body; 20 | 21 | // going to check the user role once again 22 | 23 | try { 24 | for (const [language, solutionCode] of Object.entries(referenceSolutions)) { 25 | const languageId = getJudge0LanguageId(language); 26 | 27 | if (!languageId) { 28 | return res 29 | .status(400) 30 | .json({ error: `Language ${language} is not supported` }); 31 | } 32 | 33 | // 34 | const submissions = testcases.map(({ input, output }) => ({ 35 | source_code: solutionCode, 36 | language_id: languageId, 37 | stdin: input, 38 | expected_output: output, 39 | })); 40 | 41 | const submissionResults = await submitBatch(submissions); 42 | 43 | const tokens = submissionResults.map((res) => res.token); 44 | 45 | const results = await pollBatchResults(tokens); 46 | 47 | for (let i = 0; i < results.length; i++) { 48 | const result = results[i]; 49 | console.log("Result-----", result); 50 | // console.log( 51 | // `Testcase ${i + 1} and Language ${language} ----- result ${JSON.stringify(result.status.description)}` 52 | // ); 53 | if (result.status.id !== 3) { 54 | return res.status(400).json({ 55 | error: `Testcase ${i + 1} failed for language ${language}`, 56 | }); 57 | } 58 | } 59 | } 60 | 61 | const newProblem = await db.problem.create({ 62 | data: { 63 | title, 64 | description, 65 | difficulty, 66 | tags, 67 | examples, 68 | constraints, 69 | testcases, 70 | codeSnippets, 71 | referenceSolutions, 72 | userId: req.user.id, 73 | }, 74 | }); 75 | 76 | return res.status(201).json({ 77 | sucess: true, 78 | message: "Message Created Successfully", 79 | problem: newProblem, 80 | }); 81 | } catch (error) { 82 | console.log(error); 83 | return res.status(500).json({ 84 | error: "Error While Creating Problem", 85 | }); 86 | } 87 | }; 88 | 89 | export const getAllProblems = async (req, res) => { 90 | try { 91 | const problems = await db.problem.findMany( 92 | { 93 | include:{ 94 | solvedBy:{ 95 | where:{ 96 | userId:req.user.id 97 | } 98 | } 99 | } 100 | } 101 | ); 102 | 103 | if (!problems) { 104 | return res.status(404).json({ 105 | error: "No problems Found", 106 | }); 107 | } 108 | 109 | res.status(200).json({ 110 | sucess: true, 111 | message: "Message Fetched Successfully", 112 | problems, 113 | }); 114 | } catch (error) { 115 | console.log(error); 116 | return res.status(500).json({ 117 | error: "Error While Fetching Problems", 118 | }); 119 | } 120 | }; 121 | 122 | export const getProblemById = async (req, res) => { 123 | const { id } = req.params; 124 | 125 | try { 126 | const problem = await db.problem.findUnique({ 127 | where: { 128 | id, 129 | }, 130 | }); 131 | 132 | if (!problem) { 133 | return res.status(404).json({ error: "Problem not found." }); 134 | } 135 | 136 | return res.status(200).json({ 137 | sucess: true, 138 | message: "Message Created Successfully", 139 | problem, 140 | }); 141 | } catch (error) { 142 | console.log(error); 143 | return res.status(500).json({ 144 | error: "Error While Fetching Problem by id", 145 | }); 146 | } 147 | }; 148 | 149 | // TODO: IMPLEMENT BY YOUR SELF🔥 150 | export const updateProblem = async (req, res) => { 151 | // id 152 | // id--->problem ( condition) 153 | // baaki kaam same as create 154 | }; 155 | 156 | export const deleteProblem = async (req, res) => { 157 | const { id } = req.params; 158 | 159 | try { 160 | const problem = await db.problem.findUnique({ where: { id } }); 161 | 162 | if (!problem) { 163 | return res.status(404).json({ error: "Problem Not found" }); 164 | } 165 | 166 | await db.problem.delete({ where: { id } }); 167 | 168 | res.status(200).json({ 169 | success: true, 170 | message: "Problem deleted Successfully", 171 | }); 172 | } catch (error) { 173 | console.log(error) 174 | return res.status(500).json({ 175 | error: "Error While deleting the problem", 176 | }); 177 | } 178 | }; 179 | 180 | export const getAllProblemsSolvedByUser = async (req, res) => { 181 | try { 182 | const problems = await db.problem.findMany({ 183 | where:{ 184 | solvedBy:{ 185 | some:{ 186 | userId:req.user.id 187 | } 188 | } 189 | }, 190 | include:{ 191 | solvedBy:{ 192 | where:{ 193 | userId:req.user.id 194 | } 195 | } 196 | } 197 | }) 198 | 199 | res.status(200).json({ 200 | success:true, 201 | message:"Problems fetched successfully", 202 | problems 203 | }) 204 | } catch (error) { 205 | console.error("Error fetching problems :" , error); 206 | res.status(500).json({error:"Failed to fetch problems"}) 207 | } 208 | }; 209 | -------------------------------------------------------------------------------- /backend/src/controllers/submission.controller.js: -------------------------------------------------------------------------------- 1 | import { db } from "../libs/db.js"; 2 | 3 | export const getAllSubmission = async(req , res)=>{ 4 | try { 5 | const userId = req.user.id; 6 | 7 | const submissions = await db.submission.findMany({ 8 | where:{ 9 | userId:userId 10 | } 11 | }) 12 | 13 | res.status(200).json({ 14 | success:true, 15 | message:"Submissions fetched successfully", 16 | submissions 17 | }) 18 | 19 | } catch (error) { 20 | console.error("Fetch Submissions Error:", error); 21 | res.status(500).json({ error: "Failed to fetch submissions" }); 22 | } 23 | } 24 | 25 | 26 | export const getSubmissionsForProblem = async (req , res)=>{ 27 | try { 28 | const userId = req.user.id; 29 | const problemId = req.params.problemId; 30 | const submissions = await db.submission.findMany({ 31 | where:{ 32 | userId:userId, 33 | problemId:problemId 34 | } 35 | }) 36 | 37 | res.status(200).json({ 38 | success:true, 39 | message:"Submission fetched successfully", 40 | submissions 41 | }) 42 | } catch (error) { 43 | console.error("Fetch Submissions Error:", error); 44 | res.status(500).json({ error: "Failed to fetch submissions" }); 45 | } 46 | } 47 | 48 | 49 | export const getAllTheSubmissionsForProblem = async (req , res)=>{ 50 | try { 51 | const problemId = req.params.problemId; 52 | const submission = await db.submission.count({ 53 | where:{ 54 | problemId:problemId 55 | } 56 | }) 57 | 58 | res.status(200).json({ 59 | success:true, 60 | message:"Submissions Fetched successfully", 61 | count:submission 62 | }) 63 | } catch (error) { 64 | console.error("Fetch Submissions Error:", error); 65 | res.status(500).json({ error: "Failed to fetch submissions" }); 66 | } 67 | } -------------------------------------------------------------------------------- /backend/src/generated/prisma/client.d.ts: -------------------------------------------------------------------------------- 1 | export * from "./index" -------------------------------------------------------------------------------- /backend/src/generated/prisma/client.js: -------------------------------------------------------------------------------- 1 | module.exports = { ...require('.') } -------------------------------------------------------------------------------- /backend/src/generated/prisma/default.d.ts: -------------------------------------------------------------------------------- 1 | export * from "./index" -------------------------------------------------------------------------------- /backend/src/generated/prisma/default.js: -------------------------------------------------------------------------------- 1 | module.exports = { ...require('.') } -------------------------------------------------------------------------------- /backend/src/generated/prisma/edge.d.ts: -------------------------------------------------------------------------------- 1 | export * from "./default" -------------------------------------------------------------------------------- /backend/src/generated/prisma/index-browser.js: -------------------------------------------------------------------------------- 1 | 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | 4 | const { 5 | Decimal, 6 | objectEnumValues, 7 | makeStrictEnum, 8 | Public, 9 | getRuntime, 10 | skip 11 | } = require('./runtime/index-browser.js') 12 | 13 | 14 | const Prisma = {} 15 | 16 | exports.Prisma = Prisma 17 | exports.$Enums = {} 18 | 19 | /** 20 | * Prisma Client JS version: 6.6.0 21 | * Query Engine version: f676762280b54cd07c770017ed3711ddde35f37a 22 | */ 23 | Prisma.prismaVersion = { 24 | client: "6.6.0", 25 | engine: "f676762280b54cd07c770017ed3711ddde35f37a" 26 | } 27 | 28 | Prisma.PrismaClientKnownRequestError = () => { 29 | const runtimeName = getRuntime().prettyName; 30 | throw new Error(`PrismaClientKnownRequestError is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}). 31 | In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`, 32 | )}; 33 | Prisma.PrismaClientUnknownRequestError = () => { 34 | const runtimeName = getRuntime().prettyName; 35 | throw new Error(`PrismaClientUnknownRequestError is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}). 36 | In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`, 37 | )} 38 | Prisma.PrismaClientRustPanicError = () => { 39 | const runtimeName = getRuntime().prettyName; 40 | throw new Error(`PrismaClientRustPanicError is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}). 41 | In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`, 42 | )} 43 | Prisma.PrismaClientInitializationError = () => { 44 | const runtimeName = getRuntime().prettyName; 45 | throw new Error(`PrismaClientInitializationError is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}). 46 | In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`, 47 | )} 48 | Prisma.PrismaClientValidationError = () => { 49 | const runtimeName = getRuntime().prettyName; 50 | throw new Error(`PrismaClientValidationError is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}). 51 | In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`, 52 | )} 53 | Prisma.Decimal = Decimal 54 | 55 | /** 56 | * Re-export of sql-template-tag 57 | */ 58 | Prisma.sql = () => { 59 | const runtimeName = getRuntime().prettyName; 60 | throw new Error(`sqltag is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}). 61 | In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`, 62 | )} 63 | Prisma.empty = () => { 64 | const runtimeName = getRuntime().prettyName; 65 | throw new Error(`empty is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}). 66 | In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`, 67 | )} 68 | Prisma.join = () => { 69 | const runtimeName = getRuntime().prettyName; 70 | throw new Error(`join is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}). 71 | In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`, 72 | )} 73 | Prisma.raw = () => { 74 | const runtimeName = getRuntime().prettyName; 75 | throw new Error(`raw is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}). 76 | In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`, 77 | )} 78 | Prisma.validator = Public.validator 79 | 80 | /** 81 | * Extensions 82 | */ 83 | Prisma.getExtensionContext = () => { 84 | const runtimeName = getRuntime().prettyName; 85 | throw new Error(`Extensions.getExtensionContext is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}). 86 | In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`, 87 | )} 88 | Prisma.defineExtension = () => { 89 | const runtimeName = getRuntime().prettyName; 90 | throw new Error(`Extensions.defineExtension is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}). 91 | In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`, 92 | )} 93 | 94 | /** 95 | * Shorthand utilities for JSON filtering 96 | */ 97 | Prisma.DbNull = objectEnumValues.instances.DbNull 98 | Prisma.JsonNull = objectEnumValues.instances.JsonNull 99 | Prisma.AnyNull = objectEnumValues.instances.AnyNull 100 | 101 | Prisma.NullTypes = { 102 | DbNull: objectEnumValues.classes.DbNull, 103 | JsonNull: objectEnumValues.classes.JsonNull, 104 | AnyNull: objectEnumValues.classes.AnyNull 105 | } 106 | 107 | 108 | 109 | /** 110 | * Enums 111 | */ 112 | 113 | exports.Prisma.TransactionIsolationLevel = makeStrictEnum({ 114 | ReadUncommitted: 'ReadUncommitted', 115 | ReadCommitted: 'ReadCommitted', 116 | RepeatableRead: 'RepeatableRead', 117 | Serializable: 'Serializable' 118 | }); 119 | 120 | exports.Prisma.UserScalarFieldEnum = { 121 | id: 'id', 122 | name: 'name', 123 | email: 'email', 124 | image: 'image', 125 | role: 'role', 126 | password: 'password', 127 | createdAt: 'createdAt', 128 | updatedAt: 'updatedAt' 129 | }; 130 | 131 | exports.Prisma.ProblemScalarFieldEnum = { 132 | id: 'id', 133 | title: 'title', 134 | description: 'description', 135 | difficulty: 'difficulty', 136 | tags: 'tags', 137 | userId: 'userId', 138 | examples: 'examples', 139 | constraints: 'constraints', 140 | hints: 'hints', 141 | editorial: 'editorial', 142 | testcases: 'testcases', 143 | codeSnippets: 'codeSnippets', 144 | referenceSolutions: 'referenceSolutions', 145 | createdAt: 'createdAt', 146 | updatedAt: 'updatedAt' 147 | }; 148 | 149 | exports.Prisma.SubmissionScalarFieldEnum = { 150 | id: 'id', 151 | userId: 'userId', 152 | problemId: 'problemId', 153 | sourceCode: 'sourceCode', 154 | language: 'language', 155 | stdin: 'stdin', 156 | stdout: 'stdout', 157 | stderr: 'stderr', 158 | compileOutput: 'compileOutput', 159 | status: 'status', 160 | memory: 'memory', 161 | time: 'time', 162 | createdAt: 'createdAt', 163 | updatedAt: 'updatedAt' 164 | }; 165 | 166 | exports.Prisma.TestCaseResultScalarFieldEnum = { 167 | id: 'id', 168 | submissionId: 'submissionId', 169 | testCase: 'testCase', 170 | passed: 'passed', 171 | stdout: 'stdout', 172 | expected: 'expected', 173 | stderr: 'stderr', 174 | compileOutput: 'compileOutput', 175 | status: 'status', 176 | memory: 'memory', 177 | time: 'time', 178 | createdAt: 'createdAt', 179 | updatedAt: 'updatedAt' 180 | }; 181 | 182 | exports.Prisma.ProblemSolvedScalarFieldEnum = { 183 | id: 'id', 184 | userId: 'userId', 185 | problemId: 'problemId', 186 | createdAt: 'createdAt', 187 | updatedAt: 'updatedAt' 188 | }; 189 | 190 | exports.Prisma.PlaylistScalarFieldEnum = { 191 | id: 'id', 192 | name: 'name', 193 | description: 'description', 194 | userId: 'userId', 195 | createdAt: 'createdAt', 196 | updatedAt: 'updatedAt' 197 | }; 198 | 199 | exports.Prisma.ProblemInPlaylistScalarFieldEnum = { 200 | id: 'id', 201 | playListId: 'playListId', 202 | problemId: 'problemId', 203 | createdAt: 'createdAt', 204 | updatedAt: 'updatedAt' 205 | }; 206 | 207 | exports.Prisma.SortOrder = { 208 | asc: 'asc', 209 | desc: 'desc' 210 | }; 211 | 212 | exports.Prisma.JsonNullValueInput = { 213 | JsonNull: Prisma.JsonNull 214 | }; 215 | 216 | exports.Prisma.QueryMode = { 217 | default: 'default', 218 | insensitive: 'insensitive' 219 | }; 220 | 221 | exports.Prisma.NullsOrder = { 222 | first: 'first', 223 | last: 'last' 224 | }; 225 | 226 | exports.Prisma.JsonNullValueFilter = { 227 | DbNull: Prisma.DbNull, 228 | JsonNull: Prisma.JsonNull, 229 | AnyNull: Prisma.AnyNull 230 | }; 231 | exports.UserRole = exports.$Enums.UserRole = { 232 | ADMIN: 'ADMIN', 233 | USER: 'USER' 234 | }; 235 | 236 | exports.Difficulty = exports.$Enums.Difficulty = { 237 | EASY: 'EASY', 238 | MEDIUM: 'MEDIUM', 239 | HARD: 'HARD' 240 | }; 241 | 242 | exports.Prisma.ModelName = { 243 | User: 'User', 244 | Problem: 'Problem', 245 | Submission: 'Submission', 246 | TestCaseResult: 'TestCaseResult', 247 | ProblemSolved: 'ProblemSolved', 248 | Playlist: 'Playlist', 249 | ProblemInPlaylist: 'ProblemInPlaylist' 250 | }; 251 | 252 | /** 253 | * This is a stub Prisma Client that will error at runtime if called. 254 | */ 255 | class PrismaClient { 256 | constructor() { 257 | return new Proxy(this, { 258 | get(target, prop) { 259 | let message 260 | const runtime = getRuntime() 261 | if (runtime.isEdge) { 262 | message = `PrismaClient is not configured to run in ${runtime.prettyName}. In order to run Prisma Client on edge runtime, either: 263 | - Use Prisma Accelerate: https://pris.ly/d/accelerate 264 | - Use Driver Adapters: https://pris.ly/d/driver-adapters 265 | `; 266 | } else { 267 | message = 'PrismaClient is unable to run in this browser environment, or has been bundled for the browser (running in `' + runtime.prettyName + '`).' 268 | } 269 | 270 | message += ` 271 | If this is unexpected, please open an issue: https://pris.ly/prisma-prisma-bug-report` 272 | 273 | throw new Error(message) 274 | } 275 | }) 276 | } 277 | } 278 | 279 | exports.PrismaClient = PrismaClient 280 | 281 | Object.assign(exports, Prisma) 282 | -------------------------------------------------------------------------------- /backend/src/generated/prisma/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "prisma-client-7fccf436e0db1b4b9dc94cb7a936d3801220a2257dd51d99d4cff3954743819c", 3 | "main": "index.js", 4 | "types": "index.d.ts", 5 | "browser": "index-browser.js", 6 | "exports": { 7 | "./client": { 8 | "require": { 9 | "node": "./index.js", 10 | "edge-light": "./wasm.js", 11 | "workerd": "./wasm.js", 12 | "worker": "./wasm.js", 13 | "browser": "./index-browser.js", 14 | "default": "./index.js" 15 | }, 16 | "import": { 17 | "node": "./index.js", 18 | "edge-light": "./wasm.js", 19 | "workerd": "./wasm.js", 20 | "worker": "./wasm.js", 21 | "browser": "./index-browser.js", 22 | "default": "./index.js" 23 | }, 24 | "default": "./index.js" 25 | }, 26 | "./package.json": "./package.json", 27 | ".": { 28 | "require": { 29 | "node": "./index.js", 30 | "edge-light": "./wasm.js", 31 | "workerd": "./wasm.js", 32 | "worker": "./wasm.js", 33 | "browser": "./index-browser.js", 34 | "default": "./index.js" 35 | }, 36 | "import": { 37 | "node": "./index.js", 38 | "edge-light": "./wasm.js", 39 | "workerd": "./wasm.js", 40 | "worker": "./wasm.js", 41 | "browser": "./index-browser.js", 42 | "default": "./index.js" 43 | }, 44 | "default": "./index.js" 45 | }, 46 | "./edge": { 47 | "types": "./edge.d.ts", 48 | "require": "./edge.js", 49 | "import": "./edge.js", 50 | "default": "./edge.js" 51 | }, 52 | "./react-native": { 53 | "types": "./react-native.d.ts", 54 | "require": "./react-native.js", 55 | "import": "./react-native.js", 56 | "default": "./react-native.js" 57 | }, 58 | "./extension": { 59 | "types": "./extension.d.ts", 60 | "require": "./extension.js", 61 | "import": "./extension.js", 62 | "default": "./extension.js" 63 | }, 64 | "./index-browser": { 65 | "types": "./index.d.ts", 66 | "require": "./index-browser.js", 67 | "import": "./index-browser.js", 68 | "default": "./index-browser.js" 69 | }, 70 | "./index": { 71 | "types": "./index.d.ts", 72 | "require": "./index.js", 73 | "import": "./index.js", 74 | "default": "./index.js" 75 | }, 76 | "./wasm": { 77 | "types": "./wasm.d.ts", 78 | "require": "./wasm.js", 79 | "import": "./wasm.mjs", 80 | "default": "./wasm.mjs" 81 | }, 82 | "./runtime/client": { 83 | "types": "./runtime/client.d.ts", 84 | "require": "./runtime/client.js", 85 | "import": "./runtime/client.mjs", 86 | "default": "./runtime/client.mjs" 87 | }, 88 | "./runtime/library": { 89 | "types": "./runtime/library.d.ts", 90 | "require": "./runtime/library.js", 91 | "import": "./runtime/library.mjs", 92 | "default": "./runtime/library.mjs" 93 | }, 94 | "./runtime/binary": { 95 | "types": "./runtime/binary.d.ts", 96 | "require": "./runtime/binary.js", 97 | "import": "./runtime/binary.mjs", 98 | "default": "./runtime/binary.mjs" 99 | }, 100 | "./runtime/wasm": { 101 | "types": "./runtime/wasm.d.ts", 102 | "require": "./runtime/wasm.js", 103 | "import": "./runtime/wasm.mjs", 104 | "default": "./runtime/wasm.mjs" 105 | }, 106 | "./runtime/edge": { 107 | "types": "./runtime/edge.d.ts", 108 | "require": "./runtime/edge.js", 109 | "import": "./runtime/edge-esm.js", 110 | "default": "./runtime/edge-esm.js" 111 | }, 112 | "./runtime/react-native": { 113 | "types": "./runtime/react-native.d.ts", 114 | "require": "./runtime/react-native.js", 115 | "import": "./runtime/react-native.js", 116 | "default": "./runtime/react-native.js" 117 | }, 118 | "./generator-build": { 119 | "require": "./generator-build/index.js", 120 | "import": "./generator-build/index.js", 121 | "default": "./generator-build/index.js" 122 | }, 123 | "./sql": { 124 | "require": { 125 | "types": "./sql.d.ts", 126 | "node": "./sql.js", 127 | "default": "./sql.js" 128 | }, 129 | "import": { 130 | "types": "./sql.d.ts", 131 | "node": "./sql.mjs", 132 | "default": "./sql.mjs" 133 | }, 134 | "default": "./sql.js" 135 | }, 136 | "./*": "./*" 137 | }, 138 | "version": "6.6.0", 139 | "sideEffects": false 140 | } -------------------------------------------------------------------------------- /backend/src/generated/prisma/query_engine-windows.dll.node: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aestheticsuraj234/leetlab/6f62504d449bcf691bb22da52e1fc50180c703ab/backend/src/generated/prisma/query_engine-windows.dll.node -------------------------------------------------------------------------------- /backend/src/generated/prisma/runtime/index-browser.d.ts: -------------------------------------------------------------------------------- 1 | declare class AnyNull extends NullTypesEnumValue { 2 | private readonly _brand_AnyNull; 3 | } 4 | 5 | declare type Args = T extends { 6 | [K: symbol]: { 7 | types: { 8 | operations: { 9 | [K in F]: { 10 | args: any; 11 | }; 12 | }; 13 | }; 14 | }; 15 | } ? T[symbol]['types']['operations'][F]['args'] : any; 16 | 17 | declare class DbNull extends NullTypesEnumValue { 18 | private readonly _brand_DbNull; 19 | } 20 | 21 | export declare function Decimal(n: Decimal.Value): Decimal; 22 | 23 | export declare namespace Decimal { 24 | export type Constructor = typeof Decimal; 25 | export type Instance = Decimal; 26 | export type Rounding = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8; 27 | export type Modulo = Rounding | 9; 28 | export type Value = string | number | Decimal; 29 | 30 | // http://mikemcl.github.io/decimal.js/#constructor-properties 31 | export interface Config { 32 | precision?: number; 33 | rounding?: Rounding; 34 | toExpNeg?: number; 35 | toExpPos?: number; 36 | minE?: number; 37 | maxE?: number; 38 | crypto?: boolean; 39 | modulo?: Modulo; 40 | defaults?: boolean; 41 | } 42 | } 43 | 44 | export declare class Decimal { 45 | readonly d: number[]; 46 | readonly e: number; 47 | readonly s: number; 48 | 49 | constructor(n: Decimal.Value); 50 | 51 | absoluteValue(): Decimal; 52 | abs(): Decimal; 53 | 54 | ceil(): Decimal; 55 | 56 | clampedTo(min: Decimal.Value, max: Decimal.Value): Decimal; 57 | clamp(min: Decimal.Value, max: Decimal.Value): Decimal; 58 | 59 | comparedTo(n: Decimal.Value): number; 60 | cmp(n: Decimal.Value): number; 61 | 62 | cosine(): Decimal; 63 | cos(): Decimal; 64 | 65 | cubeRoot(): Decimal; 66 | cbrt(): Decimal; 67 | 68 | decimalPlaces(): number; 69 | dp(): number; 70 | 71 | dividedBy(n: Decimal.Value): Decimal; 72 | div(n: Decimal.Value): Decimal; 73 | 74 | dividedToIntegerBy(n: Decimal.Value): Decimal; 75 | divToInt(n: Decimal.Value): Decimal; 76 | 77 | equals(n: Decimal.Value): boolean; 78 | eq(n: Decimal.Value): boolean; 79 | 80 | floor(): Decimal; 81 | 82 | greaterThan(n: Decimal.Value): boolean; 83 | gt(n: Decimal.Value): boolean; 84 | 85 | greaterThanOrEqualTo(n: Decimal.Value): boolean; 86 | gte(n: Decimal.Value): boolean; 87 | 88 | hyperbolicCosine(): Decimal; 89 | cosh(): Decimal; 90 | 91 | hyperbolicSine(): Decimal; 92 | sinh(): Decimal; 93 | 94 | hyperbolicTangent(): Decimal; 95 | tanh(): Decimal; 96 | 97 | inverseCosine(): Decimal; 98 | acos(): Decimal; 99 | 100 | inverseHyperbolicCosine(): Decimal; 101 | acosh(): Decimal; 102 | 103 | inverseHyperbolicSine(): Decimal; 104 | asinh(): Decimal; 105 | 106 | inverseHyperbolicTangent(): Decimal; 107 | atanh(): Decimal; 108 | 109 | inverseSine(): Decimal; 110 | asin(): Decimal; 111 | 112 | inverseTangent(): Decimal; 113 | atan(): Decimal; 114 | 115 | isFinite(): boolean; 116 | 117 | isInteger(): boolean; 118 | isInt(): boolean; 119 | 120 | isNaN(): boolean; 121 | 122 | isNegative(): boolean; 123 | isNeg(): boolean; 124 | 125 | isPositive(): boolean; 126 | isPos(): boolean; 127 | 128 | isZero(): boolean; 129 | 130 | lessThan(n: Decimal.Value): boolean; 131 | lt(n: Decimal.Value): boolean; 132 | 133 | lessThanOrEqualTo(n: Decimal.Value): boolean; 134 | lte(n: Decimal.Value): boolean; 135 | 136 | logarithm(n?: Decimal.Value): Decimal; 137 | log(n?: Decimal.Value): Decimal; 138 | 139 | minus(n: Decimal.Value): Decimal; 140 | sub(n: Decimal.Value): Decimal; 141 | 142 | modulo(n: Decimal.Value): Decimal; 143 | mod(n: Decimal.Value): Decimal; 144 | 145 | naturalExponential(): Decimal; 146 | exp(): Decimal; 147 | 148 | naturalLogarithm(): Decimal; 149 | ln(): Decimal; 150 | 151 | negated(): Decimal; 152 | neg(): Decimal; 153 | 154 | plus(n: Decimal.Value): Decimal; 155 | add(n: Decimal.Value): Decimal; 156 | 157 | precision(includeZeros?: boolean): number; 158 | sd(includeZeros?: boolean): number; 159 | 160 | round(): Decimal; 161 | 162 | sine() : Decimal; 163 | sin() : Decimal; 164 | 165 | squareRoot(): Decimal; 166 | sqrt(): Decimal; 167 | 168 | tangent() : Decimal; 169 | tan() : Decimal; 170 | 171 | times(n: Decimal.Value): Decimal; 172 | mul(n: Decimal.Value) : Decimal; 173 | 174 | toBinary(significantDigits?: number): string; 175 | toBinary(significantDigits: number, rounding: Decimal.Rounding): string; 176 | 177 | toDecimalPlaces(decimalPlaces?: number): Decimal; 178 | toDecimalPlaces(decimalPlaces: number, rounding: Decimal.Rounding): Decimal; 179 | toDP(decimalPlaces?: number): Decimal; 180 | toDP(decimalPlaces: number, rounding: Decimal.Rounding): Decimal; 181 | 182 | toExponential(decimalPlaces?: number): string; 183 | toExponential(decimalPlaces: number, rounding: Decimal.Rounding): string; 184 | 185 | toFixed(decimalPlaces?: number): string; 186 | toFixed(decimalPlaces: number, rounding: Decimal.Rounding): string; 187 | 188 | toFraction(max_denominator?: Decimal.Value): Decimal[]; 189 | 190 | toHexadecimal(significantDigits?: number): string; 191 | toHexadecimal(significantDigits: number, rounding: Decimal.Rounding): string; 192 | toHex(significantDigits?: number): string; 193 | toHex(significantDigits: number, rounding?: Decimal.Rounding): string; 194 | 195 | toJSON(): string; 196 | 197 | toNearest(n: Decimal.Value, rounding?: Decimal.Rounding): Decimal; 198 | 199 | toNumber(): number; 200 | 201 | toOctal(significantDigits?: number): string; 202 | toOctal(significantDigits: number, rounding: Decimal.Rounding): string; 203 | 204 | toPower(n: Decimal.Value): Decimal; 205 | pow(n: Decimal.Value): Decimal; 206 | 207 | toPrecision(significantDigits?: number): string; 208 | toPrecision(significantDigits: number, rounding: Decimal.Rounding): string; 209 | 210 | toSignificantDigits(significantDigits?: number): Decimal; 211 | toSignificantDigits(significantDigits: number, rounding: Decimal.Rounding): Decimal; 212 | toSD(significantDigits?: number): Decimal; 213 | toSD(significantDigits: number, rounding: Decimal.Rounding): Decimal; 214 | 215 | toString(): string; 216 | 217 | truncated(): Decimal; 218 | trunc(): Decimal; 219 | 220 | valueOf(): string; 221 | 222 | static abs(n: Decimal.Value): Decimal; 223 | static acos(n: Decimal.Value): Decimal; 224 | static acosh(n: Decimal.Value): Decimal; 225 | static add(x: Decimal.Value, y: Decimal.Value): Decimal; 226 | static asin(n: Decimal.Value): Decimal; 227 | static asinh(n: Decimal.Value): Decimal; 228 | static atan(n: Decimal.Value): Decimal; 229 | static atanh(n: Decimal.Value): Decimal; 230 | static atan2(y: Decimal.Value, x: Decimal.Value): Decimal; 231 | static cbrt(n: Decimal.Value): Decimal; 232 | static ceil(n: Decimal.Value): Decimal; 233 | static clamp(n: Decimal.Value, min: Decimal.Value, max: Decimal.Value): Decimal; 234 | static clone(object?: Decimal.Config): Decimal.Constructor; 235 | static config(object: Decimal.Config): Decimal.Constructor; 236 | static cos(n: Decimal.Value): Decimal; 237 | static cosh(n: Decimal.Value): Decimal; 238 | static div(x: Decimal.Value, y: Decimal.Value): Decimal; 239 | static exp(n: Decimal.Value): Decimal; 240 | static floor(n: Decimal.Value): Decimal; 241 | static hypot(...n: Decimal.Value[]): Decimal; 242 | static isDecimal(object: any): object is Decimal; 243 | static ln(n: Decimal.Value): Decimal; 244 | static log(n: Decimal.Value, base?: Decimal.Value): Decimal; 245 | static log2(n: Decimal.Value): Decimal; 246 | static log10(n: Decimal.Value): Decimal; 247 | static max(...n: Decimal.Value[]): Decimal; 248 | static min(...n: Decimal.Value[]): Decimal; 249 | static mod(x: Decimal.Value, y: Decimal.Value): Decimal; 250 | static mul(x: Decimal.Value, y: Decimal.Value): Decimal; 251 | static noConflict(): Decimal.Constructor; // Browser only 252 | static pow(base: Decimal.Value, exponent: Decimal.Value): Decimal; 253 | static random(significantDigits?: number): Decimal; 254 | static round(n: Decimal.Value): Decimal; 255 | static set(object: Decimal.Config): Decimal.Constructor; 256 | static sign(n: Decimal.Value): number; 257 | static sin(n: Decimal.Value): Decimal; 258 | static sinh(n: Decimal.Value): Decimal; 259 | static sqrt(n: Decimal.Value): Decimal; 260 | static sub(x: Decimal.Value, y: Decimal.Value): Decimal; 261 | static sum(...n: Decimal.Value[]): Decimal; 262 | static tan(n: Decimal.Value): Decimal; 263 | static tanh(n: Decimal.Value): Decimal; 264 | static trunc(n: Decimal.Value): Decimal; 265 | 266 | static readonly default?: Decimal.Constructor; 267 | static readonly Decimal?: Decimal.Constructor; 268 | 269 | static readonly precision: number; 270 | static readonly rounding: Decimal.Rounding; 271 | static readonly toExpNeg: number; 272 | static readonly toExpPos: number; 273 | static readonly minE: number; 274 | static readonly maxE: number; 275 | static readonly crypto: boolean; 276 | static readonly modulo: Decimal.Modulo; 277 | 278 | static readonly ROUND_UP: 0; 279 | static readonly ROUND_DOWN: 1; 280 | static readonly ROUND_CEIL: 2; 281 | static readonly ROUND_FLOOR: 3; 282 | static readonly ROUND_HALF_UP: 4; 283 | static readonly ROUND_HALF_DOWN: 5; 284 | static readonly ROUND_HALF_EVEN: 6; 285 | static readonly ROUND_HALF_CEIL: 7; 286 | static readonly ROUND_HALF_FLOOR: 8; 287 | static readonly EUCLID: 9; 288 | } 289 | 290 | declare type Exact = (A extends unknown ? (W extends A ? { 291 | [K in keyof A]: Exact; 292 | } : W) : never) | (A extends Narrowable ? A : never); 293 | 294 | export declare function getRuntime(): GetRuntimeOutput; 295 | 296 | declare type GetRuntimeOutput = { 297 | id: RuntimeName; 298 | prettyName: string; 299 | isEdge: boolean; 300 | }; 301 | 302 | declare class JsonNull extends NullTypesEnumValue { 303 | private readonly _brand_JsonNull; 304 | } 305 | 306 | /** 307 | * Generates more strict variant of an enum which, unlike regular enum, 308 | * throws on non-existing property access. This can be useful in following situations: 309 | * - we have an API, that accepts both `undefined` and `SomeEnumType` as an input 310 | * - enum values are generated dynamically from DMMF. 311 | * 312 | * In that case, if using normal enums and no compile-time typechecking, using non-existing property 313 | * will result in `undefined` value being used, which will be accepted. Using strict enum 314 | * in this case will help to have a runtime exception, telling you that you are probably doing something wrong. 315 | * 316 | * Note: if you need to check for existence of a value in the enum you can still use either 317 | * `in` operator or `hasOwnProperty` function. 318 | * 319 | * @param definition 320 | * @returns 321 | */ 322 | export declare function makeStrictEnum>(definition: T): T; 323 | 324 | declare type Narrowable = string | number | bigint | boolean | []; 325 | 326 | declare class NullTypesEnumValue extends ObjectEnumValue { 327 | _getNamespace(): string; 328 | } 329 | 330 | /** 331 | * Base class for unique values of object-valued enums. 332 | */ 333 | declare abstract class ObjectEnumValue { 334 | constructor(arg?: symbol); 335 | abstract _getNamespace(): string; 336 | _getName(): string; 337 | toString(): string; 338 | } 339 | 340 | export declare const objectEnumValues: { 341 | classes: { 342 | DbNull: typeof DbNull; 343 | JsonNull: typeof JsonNull; 344 | AnyNull: typeof AnyNull; 345 | }; 346 | instances: { 347 | DbNull: DbNull; 348 | JsonNull: JsonNull; 349 | AnyNull: AnyNull; 350 | }; 351 | }; 352 | 353 | declare type Operation = 'findFirst' | 'findFirstOrThrow' | 'findUnique' | 'findUniqueOrThrow' | 'findMany' | 'create' | 'createMany' | 'createManyAndReturn' | 'update' | 'updateMany' | 'updateManyAndReturn' | 'upsert' | 'delete' | 'deleteMany' | 'aggregate' | 'count' | 'groupBy' | '$queryRaw' | '$executeRaw' | '$queryRawUnsafe' | '$executeRawUnsafe' | 'findRaw' | 'aggregateRaw' | '$runCommandRaw'; 354 | 355 | declare namespace Public { 356 | export { 357 | validator 358 | } 359 | } 360 | export { Public } 361 | 362 | declare type RuntimeName = 'workerd' | 'deno' | 'netlify' | 'node' | 'bun' | 'edge-light' | ''; 363 | 364 | declare function validator(): (select: Exact) => S; 365 | 366 | declare function validator, O extends keyof C[M] & Operation>(client: C, model: M, operation: O): (select: Exact>) => S; 367 | 368 | declare function validator, O extends keyof C[M] & Operation, P extends keyof Args>(client: C, model: M, operation: O, prop: P): (select: Exact[P]>) => S; 369 | 370 | export { } 371 | -------------------------------------------------------------------------------- /backend/src/generated/prisma/runtime/index-browser.js: -------------------------------------------------------------------------------- 1 | "use strict";var ne=Object.defineProperty;var We=Object.getOwnPropertyDescriptor;var Ge=Object.getOwnPropertyNames;var Je=Object.prototype.hasOwnProperty;var Xe=(e,n,i)=>n in e?ne(e,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[n]=i;var Ce=(e,n)=>{for(var i in n)ne(e,i,{get:n[i],enumerable:!0})},Ke=(e,n,i,t)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of Ge(n))!Je.call(e,r)&&r!==i&&ne(e,r,{get:()=>n[r],enumerable:!(t=We(n,r))||t.enumerable});return e};var Qe=e=>Ke(ne({},"__esModule",{value:!0}),e);var ie=(e,n,i)=>Xe(e,typeof n!="symbol"?n+"":n,i);var yn={};Ce(yn,{Decimal:()=>je,Public:()=>ge,getRuntime:()=>Re,makeStrictEnum:()=>Oe,objectEnumValues:()=>Pe});module.exports=Qe(yn);var ge={};Ce(ge,{validator:()=>be});function be(...e){return n=>n}var te=Symbol(),me=new WeakMap,we=class{constructor(n){n===te?me.set(this,"Prisma.".concat(this._getName())):me.set(this,"new Prisma.".concat(this._getNamespace(),".").concat(this._getName(),"()"))}_getName(){return this.constructor.name}toString(){return me.get(this)}},G=class extends we{_getNamespace(){return"NullTypes"}},J=class extends G{constructor(){super(...arguments);ie(this,"_brand_DbNull")}};Ne(J,"DbNull");var X=class extends G{constructor(){super(...arguments);ie(this,"_brand_JsonNull")}};Ne(X,"JsonNull");var K=class extends G{constructor(){super(...arguments);ie(this,"_brand_AnyNull")}};Ne(K,"AnyNull");var Pe={classes:{DbNull:J,JsonNull:X,AnyNull:K},instances:{DbNull:new J(te),JsonNull:new X(te),AnyNull:new K(te)}};function Ne(e,n){Object.defineProperty(e,"name",{value:n,configurable:!0})}var Ye=new Set(["toJSON","$$typeof","asymmetricMatch",Symbol.iterator,Symbol.toStringTag,Symbol.isConcatSpreadable,Symbol.toPrimitive]);function Oe(e){return new Proxy(e,{get(n,i){if(i in n)return n[i];if(!Ye.has(i))throw new TypeError("Invalid enum value: ".concat(String(i)))}})}var xe=()=>{var e,n;return((n=(e=globalThis.process)==null?void 0:e.release)==null?void 0:n.name)==="node"},ze=()=>{var e,n;return!!globalThis.Bun||!!((n=(e=globalThis.process)==null?void 0:e.versions)!=null&&n.bun)},ye=()=>!!globalThis.Deno,en=()=>typeof globalThis.Netlify=="object",nn=()=>typeof globalThis.EdgeRuntime=="object",tn=()=>{var e;return((e=globalThis.navigator)==null?void 0:e.userAgent)==="Cloudflare-Workers"};function rn(){var i;return(i=[[en,"netlify"],[nn,"edge-light"],[tn,"workerd"],[ye,"deno"],[ze,"bun"],[xe,"node"]].flatMap(t=>t[0]()?[t[1]]:[]).at(0))!=null?i:""}var sn={node:"Node.js",workerd:"Cloudflare Workers",deno:"Deno and Deno Deploy",netlify:"Netlify Edge Functions","edge-light":"Edge Runtime (Vercel Edge Functions, Vercel Edge Middleware, Next.js (Pages Router) Edge API Routes, Next.js (App Router) Edge Route Handlers or Next.js Middleware)"};function Re(){let e=rn();return{id:e,prettyName:sn[e]||e,isEdge:["workerd","deno","netlify","edge-light"].includes(e)}}var V=9e15,H=1e9,ve="0123456789abcdef",oe="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",ue="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Ee={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-V,maxE:V,crypto:!1},Te,Z,w=!0,ce="[DecimalError] ",$=ce+"Invalid argument: ",De=ce+"Precision limit exceeded",Fe=ce+"crypto unavailable",Le="[object Decimal]",R=Math.floor,C=Math.pow,on=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,un=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,fn=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Ie=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,D=1e7,m=7,cn=9007199254740991,ln=oe.length-1,ke=ue.length-1,h={toStringTag:Le};h.absoluteValue=h.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),p(e)};h.ceil=function(){return p(new this.constructor(this),this.e+1,2)};h.clampedTo=h.clamp=function(e,n){var i,t=this,r=t.constructor;if(e=new r(e),n=new r(n),!e.s||!n.s)return new r(NaN);if(e.gt(n))throw Error($+n);return i=t.cmp(e),i<0?e:t.cmp(n)>0?n:new r(t)};h.comparedTo=h.cmp=function(e){var n,i,t,r,s=this,o=s.d,u=(e=new s.constructor(e)).d,c=s.s,f=e.s;if(!o||!u)return!c||!f?NaN:c!==f?c:o===u?0:!o^c<0?1:-1;if(!o[0]||!u[0])return o[0]?c:u[0]?-f:0;if(c!==f)return c;if(s.e!==e.e)return s.e>e.e^c<0?1:-1;for(t=o.length,r=u.length,n=0,i=tu[n]^c<0?1:-1;return t===r?0:t>r^c<0?1:-1};h.cosine=h.cos=function(){var e,n,i=this,t=i.constructor;return i.d?i.d[0]?(e=t.precision,n=t.rounding,t.precision=e+Math.max(i.e,i.sd())+m,t.rounding=1,i=an(t,He(t,i)),t.precision=e,t.rounding=n,p(Z==2||Z==3?i.neg():i,e,n,!0)):new t(1):new t(NaN)};h.cubeRoot=h.cbrt=function(){var e,n,i,t,r,s,o,u,c,f,l=this,a=l.constructor;if(!l.isFinite()||l.isZero())return new a(l);for(w=!1,s=l.s*C(l.s*l,1/3),!s||Math.abs(s)==1/0?(i=b(l.d),e=l.e,(s=(e-i.length+1)%3)&&(i+=s==1||s==-2?"0":"00"),s=C(i,1/3),e=R((e+1)/3)-(e%3==(e<0?-1:2)),s==1/0?i="5e"+e:(i=s.toExponential(),i=i.slice(0,i.indexOf("e")+1)+e),t=new a(i),t.s=l.s):t=new a(s.toString()),o=(e=a.precision)+3;;)if(u=t,c=u.times(u).times(u),f=c.plus(l),t=k(f.plus(l).times(u),f.plus(c),o+2,1),b(u.d).slice(0,o)===(i=b(t.d)).slice(0,o))if(i=i.slice(o-3,o+1),i=="9999"||!r&&i=="4999"){if(!r&&(p(u,e+1,0),u.times(u).times(u).eq(l))){t=u;break}o+=4,r=1}else{(!+i||!+i.slice(1)&&i.charAt(0)=="5")&&(p(t,e+1,1),n=!t.times(t).times(t).eq(l));break}return w=!0,p(t,e,a.rounding,n)};h.decimalPlaces=h.dp=function(){var e,n=this.d,i=NaN;if(n){if(e=n.length-1,i=(e-R(this.e/m))*m,e=n[e],e)for(;e%10==0;e/=10)i--;i<0&&(i=0)}return i};h.dividedBy=h.div=function(e){return k(this,new this.constructor(e))};h.dividedToIntegerBy=h.divToInt=function(e){var n=this,i=n.constructor;return p(k(n,new i(e),0,1,1),i.precision,i.rounding)};h.equals=h.eq=function(e){return this.cmp(e)===0};h.floor=function(){return p(new this.constructor(this),this.e+1,3)};h.greaterThan=h.gt=function(e){return this.cmp(e)>0};h.greaterThanOrEqualTo=h.gte=function(e){var n=this.cmp(e);return n==1||n===0};h.hyperbolicCosine=h.cosh=function(){var e,n,i,t,r,s=this,o=s.constructor,u=new o(1);if(!s.isFinite())return new o(s.s?1/0:NaN);if(s.isZero())return u;i=o.precision,t=o.rounding,o.precision=i+Math.max(s.e,s.sd())+4,o.rounding=1,r=s.d.length,r<32?(e=Math.ceil(r/3),n=(1/ae(4,e)).toString()):(e=16,n="2.3283064365386962890625e-10"),s=j(o,1,s.times(n),new o(1),!0);for(var c,f=e,l=new o(8);f--;)c=s.times(s),s=u.minus(c.times(l.minus(c.times(l))));return p(s,o.precision=i,o.rounding=t,!0)};h.hyperbolicSine=h.sinh=function(){var e,n,i,t,r=this,s=r.constructor;if(!r.isFinite()||r.isZero())return new s(r);if(n=s.precision,i=s.rounding,s.precision=n+Math.max(r.e,r.sd())+4,s.rounding=1,t=r.d.length,t<3)r=j(s,2,r,r,!0);else{e=1.4*Math.sqrt(t),e=e>16?16:e|0,r=r.times(1/ae(5,e)),r=j(s,2,r,r,!0);for(var o,u=new s(5),c=new s(16),f=new s(20);e--;)o=r.times(r),r=r.times(u.plus(o.times(c.times(o).plus(f))))}return s.precision=n,s.rounding=i,p(r,n,i,!0)};h.hyperbolicTangent=h.tanh=function(){var e,n,i=this,t=i.constructor;return i.isFinite()?i.isZero()?new t(i):(e=t.precision,n=t.rounding,t.precision=e+7,t.rounding=1,k(i.sinh(),i.cosh(),t.precision=e,t.rounding=n)):new t(i.s)};h.inverseCosine=h.acos=function(){var e=this,n=e.constructor,i=e.abs().cmp(1),t=n.precision,r=n.rounding;return i!==-1?i===0?e.isNeg()?F(n,t,r):new n(0):new n(NaN):e.isZero()?F(n,t+4,r).times(.5):(n.precision=t+6,n.rounding=1,e=new n(1).minus(e).div(e.plus(1)).sqrt().atan(),n.precision=t,n.rounding=r,e.times(2))};h.inverseHyperbolicCosine=h.acosh=function(){var e,n,i=this,t=i.constructor;return i.lte(1)?new t(i.eq(1)?0:NaN):i.isFinite()?(e=t.precision,n=t.rounding,t.precision=e+Math.max(Math.abs(i.e),i.sd())+4,t.rounding=1,w=!1,i=i.times(i).minus(1).sqrt().plus(i),w=!0,t.precision=e,t.rounding=n,i.ln()):new t(i)};h.inverseHyperbolicSine=h.asinh=function(){var e,n,i=this,t=i.constructor;return!i.isFinite()||i.isZero()?new t(i):(e=t.precision,n=t.rounding,t.precision=e+2*Math.max(Math.abs(i.e),i.sd())+6,t.rounding=1,w=!1,i=i.times(i).plus(1).sqrt().plus(i),w=!0,t.precision=e,t.rounding=n,i.ln())};h.inverseHyperbolicTangent=h.atanh=function(){var e,n,i,t,r=this,s=r.constructor;return r.isFinite()?r.e>=0?new s(r.abs().eq(1)?r.s/0:r.isZero()?r:NaN):(e=s.precision,n=s.rounding,t=r.sd(),Math.max(t,e)<2*-r.e-1?p(new s(r),e,n,!0):(s.precision=i=t-r.e,r=k(r.plus(1),new s(1).minus(r),i+e,1),s.precision=e+4,s.rounding=1,r=r.ln(),s.precision=e,s.rounding=n,r.times(.5))):new s(NaN)};h.inverseSine=h.asin=function(){var e,n,i,t,r=this,s=r.constructor;return r.isZero()?new s(r):(n=r.abs().cmp(1),i=s.precision,t=s.rounding,n!==-1?n===0?(e=F(s,i+4,t).times(.5),e.s=r.s,e):new s(NaN):(s.precision=i+6,s.rounding=1,r=r.div(new s(1).minus(r.times(r)).sqrt().plus(1)).atan(),s.precision=i,s.rounding=t,r.times(2)))};h.inverseTangent=h.atan=function(){var e,n,i,t,r,s,o,u,c,f=this,l=f.constructor,a=l.precision,d=l.rounding;if(f.isFinite()){if(f.isZero())return new l(f);if(f.abs().eq(1)&&a+4<=ke)return o=F(l,a+4,d).times(.25),o.s=f.s,o}else{if(!f.s)return new l(NaN);if(a+4<=ke)return o=F(l,a+4,d).times(.5),o.s=f.s,o}for(l.precision=u=a+10,l.rounding=1,i=Math.min(28,u/m+2|0),e=i;e;--e)f=f.div(f.times(f).plus(1).sqrt().plus(1));for(w=!1,n=Math.ceil(u/m),t=1,c=f.times(f),o=new l(f),r=f;e!==-1;)if(r=r.times(c),s=o.minus(r.div(t+=2)),r=r.times(c),o=s.plus(r.div(t+=2)),o.d[n]!==void 0)for(e=n;o.d[e]===s.d[e]&&e--;);return i&&(o=o.times(2<this.d.length-2};h.isNaN=function(){return!this.s};h.isNegative=h.isNeg=function(){return this.s<0};h.isPositive=h.isPos=function(){return this.s>0};h.isZero=function(){return!!this.d&&this.d[0]===0};h.lessThan=h.lt=function(e){return this.cmp(e)<0};h.lessThanOrEqualTo=h.lte=function(e){return this.cmp(e)<1};h.logarithm=h.log=function(e){var n,i,t,r,s,o,u,c,f=this,l=f.constructor,a=l.precision,d=l.rounding,g=5;if(e==null)e=new l(10),n=!0;else{if(e=new l(e),i=e.d,e.s<0||!i||!i[0]||e.eq(1))return new l(NaN);n=e.eq(10)}if(i=f.d,f.s<0||!i||!i[0]||f.eq(1))return new l(i&&!i[0]?-1/0:f.s!=1?NaN:i?0:1/0);if(n)if(i.length>1)s=!0;else{for(r=i[0];r%10===0;)r/=10;s=r!==1}if(w=!1,u=a+g,o=B(f,u),t=n?fe(l,u+10):B(e,u),c=k(o,t,u,1),Q(c.d,r=a,d))do if(u+=10,o=B(f,u),t=n?fe(l,u+10):B(e,u),c=k(o,t,u,1),!s){+b(c.d).slice(r+1,r+15)+1==1e14&&(c=p(c,a+1,0));break}while(Q(c.d,r+=10,d));return w=!0,p(c,a,d)};h.minus=h.sub=function(e){var n,i,t,r,s,o,u,c,f,l,a,d,g=this,v=g.constructor;if(e=new v(e),!g.d||!e.d)return!g.s||!e.s?e=new v(NaN):g.d?e.s=-e.s:e=new v(e.d||g.s!==e.s?g:NaN),e;if(g.s!=e.s)return e.s=-e.s,g.plus(e);if(f=g.d,d=e.d,u=v.precision,c=v.rounding,!f[0]||!d[0]){if(d[0])e.s=-e.s;else if(f[0])e=new v(g);else return new v(c===3?-0:0);return w?p(e,u,c):e}if(i=R(e.e/m),l=R(g.e/m),f=f.slice(),s=l-i,s){for(a=s<0,a?(n=f,s=-s,o=d.length):(n=d,i=l,o=f.length),t=Math.max(Math.ceil(u/m),o)+2,s>t&&(s=t,n.length=1),n.reverse(),t=s;t--;)n.push(0);n.reverse()}else{for(t=f.length,o=d.length,a=t0;--t)f[o++]=0;for(t=d.length;t>s;){if(f[--t]o?s+1:o+1,r>o&&(r=o,i.length=1),i.reverse();r--;)i.push(0);i.reverse()}for(o=f.length,r=l.length,o-r<0&&(r=o,i=l,l=f,f=i),n=0;r;)n=(f[--r]=f[r]+l[r]+n)/D|0,f[r]%=D;for(n&&(f.unshift(n),++t),o=f.length;f[--o]==0;)f.pop();return e.d=f,e.e=le(f,t),w?p(e,u,c):e};h.precision=h.sd=function(e){var n,i=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error($+e);return i.d?(n=Ze(i.d),e&&i.e+1>n&&(n=i.e+1)):n=NaN,n};h.round=function(){var e=this,n=e.constructor;return p(new n(e),e.e+1,n.rounding)};h.sine=h.sin=function(){var e,n,i=this,t=i.constructor;return i.isFinite()?i.isZero()?new t(i):(e=t.precision,n=t.rounding,t.precision=e+Math.max(i.e,i.sd())+m,t.rounding=1,i=hn(t,He(t,i)),t.precision=e,t.rounding=n,p(Z>2?i.neg():i,e,n,!0)):new t(NaN)};h.squareRoot=h.sqrt=function(){var e,n,i,t,r,s,o=this,u=o.d,c=o.e,f=o.s,l=o.constructor;if(f!==1||!u||!u[0])return new l(!f||f<0&&(!u||u[0])?NaN:u?o:1/0);for(w=!1,f=Math.sqrt(+o),f==0||f==1/0?(n=b(u),(n.length+c)%2==0&&(n+="0"),f=Math.sqrt(n),c=R((c+1)/2)-(c<0||c%2),f==1/0?n="5e"+c:(n=f.toExponential(),n=n.slice(0,n.indexOf("e")+1)+c),t=new l(n)):t=new l(f.toString()),i=(c=l.precision)+3;;)if(s=t,t=s.plus(k(o,s,i+2,1)).times(.5),b(s.d).slice(0,i)===(n=b(t.d)).slice(0,i))if(n=n.slice(i-3,i+1),n=="9999"||!r&&n=="4999"){if(!r&&(p(s,c+1,0),s.times(s).eq(o))){t=s;break}i+=4,r=1}else{(!+n||!+n.slice(1)&&n.charAt(0)=="5")&&(p(t,c+1,1),e=!t.times(t).eq(o));break}return w=!0,p(t,c,l.rounding,e)};h.tangent=h.tan=function(){var e,n,i=this,t=i.constructor;return i.isFinite()?i.isZero()?new t(i):(e=t.precision,n=t.rounding,t.precision=e+10,t.rounding=1,i=i.sin(),i.s=1,i=k(i,new t(1).minus(i.times(i)).sqrt(),e+10,0),t.precision=e,t.rounding=n,p(Z==2||Z==4?i.neg():i,e,n,!0)):new t(NaN)};h.times=h.mul=function(e){var n,i,t,r,s,o,u,c,f,l=this,a=l.constructor,d=l.d,g=(e=new a(e)).d;if(e.s*=l.s,!d||!d[0]||!g||!g[0])return new a(!e.s||d&&!d[0]&&!g||g&&!g[0]&&!d?NaN:!d||!g?e.s/0:e.s*0);for(i=R(l.e/m)+R(e.e/m),c=d.length,f=g.length,c=0;){for(n=0,r=c+t;r>t;)u=s[r]+g[t]*d[r-t-1]+n,s[r--]=u%D|0,n=u/D|0;s[r]=(s[r]+n)%D|0}for(;!s[--o];)s.pop();return n?++i:s.shift(),e.d=s,e.e=le(s,i),w?p(e,a.precision,a.rounding):e};h.toBinary=function(e,n){return Me(this,2,e,n)};h.toDecimalPlaces=h.toDP=function(e,n){var i=this,t=i.constructor;return i=new t(i),e===void 0?i:(q(e,0,H),n===void 0?n=t.rounding:q(n,0,8),p(i,e+i.e+1,n))};h.toExponential=function(e,n){var i,t=this,r=t.constructor;return e===void 0?i=L(t,!0):(q(e,0,H),n===void 0?n=r.rounding:q(n,0,8),t=p(new r(t),e+1,n),i=L(t,!0,e+1)),t.isNeg()&&!t.isZero()?"-"+i:i};h.toFixed=function(e,n){var i,t,r=this,s=r.constructor;return e===void 0?i=L(r):(q(e,0,H),n===void 0?n=s.rounding:q(n,0,8),t=p(new s(r),e+r.e+1,n),i=L(t,!1,e+t.e+1)),r.isNeg()&&!r.isZero()?"-"+i:i};h.toFraction=function(e){var n,i,t,r,s,o,u,c,f,l,a,d,g=this,v=g.d,N=g.constructor;if(!v)return new N(g);if(f=i=new N(1),t=c=new N(0),n=new N(t),s=n.e=Ze(v)-g.e-1,o=s%m,n.d[0]=C(10,o<0?m+o:o),e==null)e=s>0?n:f;else{if(u=new N(e),!u.isInt()||u.lt(f))throw Error($+u);e=u.gt(n)?s>0?n:f:u}for(w=!1,u=new N(b(v)),l=N.precision,N.precision=s=v.length*m*2;a=k(u,n,0,1,1),r=i.plus(a.times(t)),r.cmp(e)!=1;)i=t,t=r,r=f,f=c.plus(a.times(r)),c=r,r=n,n=u.minus(a.times(r)),u=r;return r=k(e.minus(i),t,0,1,1),c=c.plus(r.times(f)),i=i.plus(r.times(t)),c.s=f.s=g.s,d=k(f,t,s,1).minus(g).abs().cmp(k(c,i,s,1).minus(g).abs())<1?[f,t]:[c,i],N.precision=l,w=!0,d};h.toHexadecimal=h.toHex=function(e,n){return Me(this,16,e,n)};h.toNearest=function(e,n){var i=this,t=i.constructor;if(i=new t(i),e==null){if(!i.d)return i;e=new t(1),n=t.rounding}else{if(e=new t(e),n===void 0?n=t.rounding:q(n,0,8),!i.d)return e.s?i:e;if(!e.d)return e.s&&(e.s=i.s),e}return e.d[0]?(w=!1,i=k(i,e,0,n,1).times(e),w=!0,p(i)):(e.s=i.s,i=e),i};h.toNumber=function(){return+this};h.toOctal=function(e,n){return Me(this,8,e,n)};h.toPower=h.pow=function(e){var n,i,t,r,s,o,u=this,c=u.constructor,f=+(e=new c(e));if(!u.d||!e.d||!u.d[0]||!e.d[0])return new c(C(+u,f));if(u=new c(u),u.eq(1))return u;if(t=c.precision,s=c.rounding,e.eq(1))return p(u,t,s);if(n=R(e.e/m),n>=e.d.length-1&&(i=f<0?-f:f)<=cn)return r=Ue(c,u,i,t),e.s<0?new c(1).div(r):p(r,t,s);if(o=u.s,o<0){if(nc.maxE+1||n0?o/0:0):(w=!1,c.rounding=u.s=1,i=Math.min(12,(n+"").length),r=Se(e.times(B(u,t+i)),t),r.d&&(r=p(r,t+5,1),Q(r.d,t,s)&&(n=t+10,r=p(Se(e.times(B(u,n+i)),n),n+5,1),+b(r.d).slice(t+1,t+15)+1==1e14&&(r=p(r,t+1,0)))),r.s=o,w=!0,c.rounding=s,p(r,t,s))};h.toPrecision=function(e,n){var i,t=this,r=t.constructor;return e===void 0?i=L(t,t.e<=r.toExpNeg||t.e>=r.toExpPos):(q(e,1,H),n===void 0?n=r.rounding:q(n,0,8),t=p(new r(t),e,n),i=L(t,e<=t.e||t.e<=r.toExpNeg,e)),t.isNeg()&&!t.isZero()?"-"+i:i};h.toSignificantDigits=h.toSD=function(e,n){var i=this,t=i.constructor;return e===void 0?(e=t.precision,n=t.rounding):(q(e,1,H),n===void 0?n=t.rounding:q(n,0,8)),p(new t(i),e,n)};h.toString=function(){var e=this,n=e.constructor,i=L(e,e.e<=n.toExpNeg||e.e>=n.toExpPos);return e.isNeg()&&!e.isZero()?"-"+i:i};h.truncated=h.trunc=function(){return p(new this.constructor(this),this.e+1,1)};h.valueOf=h.toJSON=function(){var e=this,n=e.constructor,i=L(e,e.e<=n.toExpNeg||e.e>=n.toExpPos);return e.isNeg()?"-"+i:i};function b(e){var n,i,t,r=e.length-1,s="",o=e[0];if(r>0){for(s+=o,n=1;ni)throw Error($+e)}function Q(e,n,i,t){var r,s,o,u;for(s=e[0];s>=10;s/=10)--n;return--n<0?(n+=m,r=0):(r=Math.ceil((n+1)/m),n%=m),s=C(10,m-n),u=e[r]%s|0,t==null?n<3?(n==0?u=u/100|0:n==1&&(u=u/10|0),o=i<4&&u==99999||i>3&&u==49999||u==5e4||u==0):o=(i<4&&u+1==s||i>3&&u+1==s/2)&&(e[r+1]/s/100|0)==C(10,n-2)-1||(u==s/2||u==0)&&(e[r+1]/s/100|0)==0:n<4?(n==0?u=u/1e3|0:n==1?u=u/100|0:n==2&&(u=u/10|0),o=(t||i<4)&&u==9999||!t&&i>3&&u==4999):o=((t||i<4)&&u+1==s||!t&&i>3&&u+1==s/2)&&(e[r+1]/s/1e3|0)==C(10,n-3)-1,o}function re(e,n,i){for(var t,r=[0],s,o=0,u=e.length;oi-1&&(r[t+1]===void 0&&(r[t+1]=0),r[t+1]+=r[t]/i|0,r[t]%=i)}return r.reverse()}function an(e,n){var i,t,r;if(n.isZero())return n;t=n.d.length,t<32?(i=Math.ceil(t/3),r=(1/ae(4,i)).toString()):(i=16,r="2.3283064365386962890625e-10"),e.precision+=i,n=j(e,1,n.times(r),new e(1));for(var s=i;s--;){var o=n.times(n);n=o.times(o).minus(o).times(8).plus(1)}return e.precision-=i,n}var k=function(){function e(t,r,s){var o,u=0,c=t.length;for(t=t.slice();c--;)o=t[c]*r+u,t[c]=o%s|0,u=o/s|0;return u&&t.unshift(u),t}function n(t,r,s,o){var u,c;if(s!=o)c=s>o?1:-1;else for(u=c=0;ur[u]?1:-1;break}return c}function i(t,r,s,o){for(var u=0;s--;)t[s]-=u,u=t[s]1;)t.shift()}return function(t,r,s,o,u,c){var f,l,a,d,g,v,N,A,M,_,E,P,x,I,de,z,W,he,T,y,ee=t.constructor,pe=t.s==r.s?1:-1,O=t.d,S=r.d;if(!O||!O[0]||!S||!S[0])return new ee(!t.s||!r.s||(O?S&&O[0]==S[0]:!S)?NaN:O&&O[0]==0||!S?pe*0:pe/0);for(c?(g=1,l=t.e-r.e):(c=D,g=m,l=R(t.e/g)-R(r.e/g)),T=S.length,W=O.length,M=new ee(pe),_=M.d=[],a=0;S[a]==(O[a]||0);a++);if(S[a]>(O[a]||0)&&l--,s==null?(I=s=ee.precision,o=ee.rounding):u?I=s+(t.e-r.e)+1:I=s,I<0)_.push(1),v=!0;else{if(I=I/g+2|0,a=0,T==1){for(d=0,S=S[0],I++;(a1&&(S=e(S,d,c),O=e(O,d,c),T=S.length,W=O.length),z=T,E=O.slice(0,T),P=E.length;P=c/2&&++he;do d=0,f=n(S,E,T,P),f<0?(x=E[0],T!=P&&(x=x*c+(E[1]||0)),d=x/he|0,d>1?(d>=c&&(d=c-1),N=e(S,d,c),A=N.length,P=E.length,f=n(N,E,A,P),f==1&&(d--,i(N,T=10;d/=10)a++;M.e=a+l*g-1,p(M,u?s+M.e+1:s,o,v)}return M}}();function p(e,n,i,t){var r,s,o,u,c,f,l,a,d,g=e.constructor;e:if(n!=null){if(a=e.d,!a)return e;for(r=1,u=a[0];u>=10;u/=10)r++;if(s=n-r,s<0)s+=m,o=n,l=a[d=0],c=l/C(10,r-o-1)%10|0;else if(d=Math.ceil((s+1)/m),u=a.length,d>=u)if(t){for(;u++<=d;)a.push(0);l=c=0,r=1,s%=m,o=s-m+1}else break e;else{for(l=u=a[d],r=1;u>=10;u/=10)r++;s%=m,o=s-m+r,c=o<0?0:l/C(10,r-o-1)%10|0}if(t=t||n<0||a[d+1]!==void 0||(o<0?l:l%C(10,r-o-1)),f=i<4?(c||t)&&(i==0||i==(e.s<0?3:2)):c>5||c==5&&(i==4||t||i==6&&(s>0?o>0?l/C(10,r-o):0:a[d-1])%10&1||i==(e.s<0?8:7)),n<1||!a[0])return a.length=0,f?(n-=e.e+1,a[0]=C(10,(m-n%m)%m),e.e=-n||0):a[0]=e.e=0,e;if(s==0?(a.length=d,u=1,d--):(a.length=d+1,u=C(10,m-s),a[d]=o>0?(l/C(10,r-o)%C(10,o)|0)*u:0),f)for(;;)if(d==0){for(s=1,o=a[0];o>=10;o/=10)s++;for(o=a[0]+=u,u=1;o>=10;o/=10)u++;s!=u&&(e.e++,a[0]==D&&(a[0]=1));break}else{if(a[d]+=u,a[d]!=D)break;a[d--]=0,u=1}for(s=a.length;a[--s]===0;)a.pop()}return w&&(e.e>g.maxE?(e.d=null,e.e=NaN):e.e0?s=s.charAt(0)+"."+s.slice(1)+U(t):o>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(e.e<0?"e":"e+")+e.e):r<0?(s="0."+U(-r-1)+s,i&&(t=i-o)>0&&(s+=U(t))):r>=o?(s+=U(r+1-o),i&&(t=i-r-1)>0&&(s=s+"."+U(t))):((t=r+1)0&&(r+1===o&&(s+="."),s+=U(t))),s}function le(e,n){var i=e[0];for(n*=m;i>=10;i/=10)n++;return n}function fe(e,n,i){if(n>ln)throw w=!0,i&&(e.precision=i),Error(De);return p(new e(oe),n,1,!0)}function F(e,n,i){if(n>ke)throw Error(De);return p(new e(ue),n,i,!0)}function Ze(e){var n=e.length-1,i=n*m+1;if(n=e[n],n){for(;n%10==0;n/=10)i--;for(n=e[0];n>=10;n/=10)i++}return i}function U(e){for(var n="";e--;)n+="0";return n}function Ue(e,n,i,t){var r,s=new e(1),o=Math.ceil(t/m+4);for(w=!1;;){if(i%2&&(s=s.times(n),qe(s.d,o)&&(r=!0)),i=R(i/2),i===0){i=s.d.length-1,r&&s.d[i]===0&&++s.d[i];break}n=n.times(n),qe(n.d,o)}return w=!0,s}function Ae(e){return e.d[e.d.length-1]&1}function Be(e,n,i){for(var t,r,s=new e(n[0]),o=0;++o17)return new d(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:NaN);for(n==null?(w=!1,c=v):c=n,u=new d(.03125);e.e>-2;)e=e.times(u),a+=5;for(t=Math.log(C(2,a))/Math.LN10*2+5|0,c+=t,i=s=o=new d(1),d.precision=c;;){if(s=p(s.times(e),c,1),i=i.times(++l),u=o.plus(k(s,i,c,1)),b(u.d).slice(0,c)===b(o.d).slice(0,c)){for(r=a;r--;)o=p(o.times(o),c,1);if(n==null)if(f<3&&Q(o.d,c-t,g,f))d.precision=c+=10,i=s=u=new d(1),l=0,f++;else return p(o,d.precision=v,g,w=!0);else return d.precision=v,o}o=u}}function B(e,n){var i,t,r,s,o,u,c,f,l,a,d,g=1,v=10,N=e,A=N.d,M=N.constructor,_=M.rounding,E=M.precision;if(N.s<0||!A||!A[0]||!N.e&&A[0]==1&&A.length==1)return new M(A&&!A[0]?-1/0:N.s!=1?NaN:A?0:N);if(n==null?(w=!1,l=E):l=n,M.precision=l+=v,i=b(A),t=i.charAt(0),Math.abs(s=N.e)<15e14){for(;t<7&&t!=1||t==1&&i.charAt(1)>3;)N=N.times(e),i=b(N.d),t=i.charAt(0),g++;s=N.e,t>1?(N=new M("0."+i),s++):N=new M(t+"."+i.slice(1))}else return f=fe(M,l+2,E).times(s+""),N=B(new M(t+"."+i.slice(1)),l-v).plus(f),M.precision=E,n==null?p(N,E,_,w=!0):N;for(a=N,c=o=N=k(N.minus(1),N.plus(1),l,1),d=p(N.times(N),l,1),r=3;;){if(o=p(o.times(d),l,1),f=c.plus(k(o,new M(r),l,1)),b(f.d).slice(0,l)===b(c.d).slice(0,l))if(c=c.times(2),s!==0&&(c=c.plus(fe(M,l+2,E).times(s+""))),c=k(c,new M(g),l,1),n==null)if(Q(c.d,l-v,_,u))M.precision=l+=v,f=o=N=k(a.minus(1),a.plus(1),l,1),d=p(N.times(N),l,1),r=u=1;else return p(c,M.precision=E,_,w=!0);else return M.precision=E,c;c=f,r+=2}}function $e(e){return String(e.s*e.s/0)}function se(e,n){var i,t,r;for((i=n.indexOf("."))>-1&&(n=n.replace(".","")),(t=n.search(/e/i))>0?(i<0&&(i=t),i+=+n.slice(t+1),n=n.substring(0,t)):i<0&&(i=n.length),t=0;n.charCodeAt(t)===48;t++);for(r=n.length;n.charCodeAt(r-1)===48;--r);if(n=n.slice(t,r),n){if(r-=t,e.e=i=i-t-1,e.d=[],t=(i+1)%m,i<0&&(t+=m),te.constructor.maxE?(e.d=null,e.e=NaN):e.e-1){if(n=n.replace(/(\d)_(?=\d)/g,"$1"),Ie.test(n))return se(e,n)}else if(n==="Infinity"||n==="NaN")return+n||(e.s=NaN),e.e=NaN,e.d=null,e;if(un.test(n))i=16,n=n.toLowerCase();else if(on.test(n))i=2;else if(fn.test(n))i=8;else throw Error($+n);for(s=n.search(/p/i),s>0?(c=+n.slice(s+1),n=n.substring(2,s)):n=n.slice(2),s=n.indexOf("."),o=s>=0,t=e.constructor,o&&(n=n.replace(".",""),u=n.length,s=u-s,r=Ue(t,new t(i),s,s*2)),f=re(n,i,D),l=f.length-1,s=l;f[s]===0;--s)f.pop();return s<0?new t(e.s*0):(e.e=le(f,l),e.d=f,w=!1,o&&(e=k(e,r,u*4)),c&&(e=e.times(Math.abs(c)<54?C(2,c):Y.pow(2,c))),w=!0,e)}function hn(e,n){var i,t=n.d.length;if(t<3)return n.isZero()?n:j(e,2,n,n);i=1.4*Math.sqrt(t),i=i>16?16:i|0,n=n.times(1/ae(5,i)),n=j(e,2,n,n);for(var r,s=new e(5),o=new e(16),u=new e(20);i--;)r=n.times(n),n=n.times(s.plus(r.times(o.times(r).minus(u))));return n}function j(e,n,i,t,r){var s,o,u,c,f=1,l=e.precision,a=Math.ceil(l/m);for(w=!1,c=i.times(i),u=new e(t);;){if(o=k(u.times(c),new e(n++*n++),l,1),u=r?t.plus(o):t.minus(o),t=k(o.times(c),new e(n++*n++),l,1),o=u.plus(t),o.d[a]!==void 0){for(s=a;o.d[s]===u.d[s]&&s--;);if(s==-1)break}s=u,u=t,t=o,o=s,f++}return w=!0,o.d.length=a+1,o}function ae(e,n){for(var i=e;--n;)i*=e;return i}function He(e,n){var i,t=n.s<0,r=F(e,e.precision,1),s=r.times(.5);if(n=n.abs(),n.lte(s))return Z=t?4:1,n;if(i=n.divToInt(r),i.isZero())Z=t?3:2;else{if(n=n.minus(i.times(r)),n.lte(s))return Z=Ae(i)?t?2:3:t?4:1,n;Z=Ae(i)?t?1:4:t?3:2}return n.minus(r).abs()}function Me(e,n,i,t){var r,s,o,u,c,f,l,a,d,g=e.constructor,v=i!==void 0;if(v?(q(i,1,H),t===void 0?t=g.rounding:q(t,0,8)):(i=g.precision,t=g.rounding),!e.isFinite())l=$e(e);else{for(l=L(e),o=l.indexOf("."),v?(r=2,n==16?i=i*4-3:n==8&&(i=i*3-2)):r=n,o>=0&&(l=l.replace(".",""),d=new g(1),d.e=l.length-o,d.d=re(L(d),10,r),d.e=d.d.length),a=re(l,10,r),s=c=a.length;a[--c]==0;)a.pop();if(!a[0])l=v?"0p+0":"0";else{if(o<0?s--:(e=new g(e),e.d=a,e.e=s,e=k(e,d,i,t,0,r),a=e.d,s=e.e,f=Te),o=a[i],u=r/2,f=f||a[i+1]!==void 0,f=t<4?(o!==void 0||f)&&(t===0||t===(e.s<0?3:2)):o>u||o===u&&(t===4||f||t===6&&a[i-1]&1||t===(e.s<0?8:7)),a.length=i,f)for(;++a[--i]>r-1;)a[i]=0,i||(++s,a.unshift(1));for(c=a.length;!a[c-1];--c);for(o=0,l="";o1)if(n==16||n==8){for(o=n==16?4:3,--c;c%o;c++)l+="0";for(a=re(l,r,n),c=a.length;!a[c-1];--c);for(o=1,l="1.";oc)for(s-=c;s--;)l+="0";else sn)return e.length=n,!0}function pn(e){return new this(e).abs()}function gn(e){return new this(e).acos()}function mn(e){return new this(e).acosh()}function wn(e,n){return new this(e).plus(n)}function Nn(e){return new this(e).asin()}function vn(e){return new this(e).asinh()}function En(e){return new this(e).atan()}function kn(e){return new this(e).atanh()}function Sn(e,n){e=new this(e),n=new this(n);var i,t=this.precision,r=this.rounding,s=t+4;return!e.s||!n.s?i=new this(NaN):!e.d&&!n.d?(i=F(this,s,1).times(n.s>0?.25:.75),i.s=e.s):!n.d||e.isZero()?(i=n.s<0?F(this,t,r):new this(0),i.s=e.s):!e.d||n.isZero()?(i=F(this,s,1).times(.5),i.s=e.s):n.s<0?(this.precision=s,this.rounding=1,i=this.atan(k(e,n,s,1)),n=F(this,s,1),this.precision=t,this.rounding=r,i=e.s<0?i.minus(n):i.plus(n)):i=this.atan(k(e,n,s,1)),i}function Mn(e){return new this(e).cbrt()}function Cn(e){return p(e=new this(e),e.e+1,2)}function bn(e,n,i){return new this(e).clamp(n,i)}function Pn(e){if(!e||typeof e!="object")throw Error(ce+"Object expected");var n,i,t,r=e.defaults===!0,s=["precision",1,H,"rounding",0,8,"toExpNeg",-V,0,"toExpPos",0,V,"maxE",0,V,"minE",-V,0,"modulo",0,9];for(n=0;n=s[n+1]&&t<=s[n+2])this[i]=t;else throw Error($+i+": "+t);if(i="crypto",r&&(this[i]=Ee[i]),(t=e[i])!==void 0)if(t===!0||t===!1||t===0||t===1)if(t)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[i]=!0;else throw Error(Fe);else this[i]=!1;else throw Error($+i+": "+t);return this}function On(e){return new this(e).cos()}function Rn(e){return new this(e).cosh()}function Ve(e){var n,i,t;function r(s){var o,u,c,f=this;if(!(f instanceof r))return new r(s);if(f.constructor=r,_e(s)){f.s=s.s,w?!s.d||s.e>r.maxE?(f.e=NaN,f.d=null):s.e=10;u/=10)o++;w?o>r.maxE?(f.e=NaN,f.d=null):o=429e7?n[s]=crypto.getRandomValues(new Uint32Array(1))[0]:u[s++]=r%1e7;else if(crypto.randomBytes){for(n=crypto.randomBytes(t*=4);s=214e7?crypto.randomBytes(4).copy(n,s):(u.push(r%1e7),s+=4);s=t/4}else throw Error(Fe);else for(;s=10;r/=10)t++;t 10 | * MIT Licence 11 | *) 12 | */ 13 | //# sourceMappingURL=index-browser.js.map 14 | -------------------------------------------------------------------------------- /backend/src/generated/prisma/schema.prisma: -------------------------------------------------------------------------------- 1 | // This is your Prisma schema file, 2 | // learn more about it in the docs: https://pris.ly/d/prisma-schema 3 | 4 | // Looking for ways to speed up your queries, or scale easily with your serverless or edge functions? 5 | // Try Prisma Accelerate: https://pris.ly/cli/accelerate-init 6 | 7 | generator client { 8 | provider = "prisma-client-js" 9 | output = "../src/generated/prisma" 10 | } 11 | 12 | datasource db { 13 | provider = "postgresql" 14 | url = env("DATABASE_URL") 15 | } 16 | 17 | enum UserRole { 18 | ADMIN 19 | USER 20 | } 21 | 22 | enum Difficulty { 23 | EASY 24 | MEDIUM 25 | HARD 26 | } 27 | 28 | model User { 29 | id String @id @default(uuid()) 30 | name String? 31 | email String @unique 32 | image String? 33 | role UserRole @default(USER) 34 | password String 35 | createdAt DateTime @default(now()) 36 | updatedAt DateTime @updatedAt 37 | 38 | problems Problem[] 39 | submission Submission[] 40 | problemSolved ProblemSolved[] 41 | playlists Playlist[] 42 | } 43 | 44 | model Problem { 45 | id String @id @default(uuid()) 46 | title String 47 | description String 48 | difficulty Difficulty 49 | tags String[] // ["tag1", "tag2", "tag3"] 50 | userId String 51 | examples Json 52 | constraints String 53 | hints String? 54 | editorial String? 55 | 56 | testcases Json // 57 | codeSnippets Json 58 | referenceSolutions Json 59 | 60 | createdAt DateTime @default(now()) 61 | updatedAt DateTime @updatedAt 62 | 63 | // Relationship 64 | user User @relation(fields: [userId], references: [id], onDelete: Cascade) 65 | submission Submission[] 66 | solvedBy ProblemSolved[] 67 | problemsPlaylists ProblemInPlaylist[] 68 | } 69 | 70 | // enum Status{ 71 | // ACCEPTED 72 | // WORNG_ANSWER 73 | // } 74 | 75 | model Submission { 76 | id String @id @default(uuid()) 77 | userId String 78 | problemId String 79 | sourceCode Json 80 | language String 81 | stdin String? 82 | stdout String? 83 | stderr String? 84 | compileOutput String? 85 | status String // Accepted , wrong answer 86 | memory String? 87 | time String? 88 | 89 | createdAt DateTime @default(now()) 90 | updatedAt DateTime @updatedAt 91 | 92 | user User @relation(fields: [userId], references: [id], onDelete: Cascade) 93 | problem Problem @relation(fields: [problemId], references: [id], onDelete: Cascade) 94 | 95 | testCases TestCaseResult[] 96 | } 97 | 98 | model TestCaseResult { 99 | id String @id @default(uuid()) 100 | submissionId String 101 | testCase Int 102 | passed Boolean 103 | stdout String? 104 | expected String 105 | stderr String? 106 | compileOutput String? 107 | status String 108 | memory String? 109 | time String? 110 | 111 | createdAt DateTime @default(now()) 112 | updatedAt DateTime @updatedAt 113 | 114 | submission Submission @relation(fields: [submissionId], references: [id], onDelete: Cascade) 115 | 116 | @@index([submissionId]) 117 | } 118 | 119 | model ProblemSolved { 120 | id String @id @default(uuid()) 121 | userId String 122 | problemId String 123 | createdAt DateTime @default(now()) 124 | updatedAt DateTime @updatedAt 125 | 126 | user User @relation(fields: [userId], references: [id], onDelete: Cascade) 127 | problem Problem @relation(fields: [problemId], references: [id], onDelete: Cascade) 128 | 129 | @@unique([userId, problemId]) 130 | } 131 | 132 | model Playlist { 133 | id String @id @default(uuid()) 134 | name String 135 | description String? 136 | userId String 137 | 138 | createdAt DateTime @default(now()) 139 | updatedAt DateTime @updatedAt 140 | 141 | problems ProblemInPlaylist[] 142 | 143 | user User @relation(fields: [userId], references: [id], onDelete: Cascade) 144 | 145 | @@unique([name, userId]) // unique playlist names per user 146 | } 147 | 148 | model ProblemInPlaylist { 149 | id String @id @default(uuid()) 150 | playListId String 151 | problemId String 152 | createdAt DateTime @default(now()) 153 | updatedAt DateTime @updatedAt 154 | 155 | playlist Playlist @relation(fields: [playListId], references: [id], onDelete: Cascade) 156 | problem Problem @relation(fields: [problemId], references: [id], onDelete: Cascade) 157 | 158 | @@unique([playListId, problemId]) 159 | } 160 | -------------------------------------------------------------------------------- /backend/src/generated/prisma/wasm.d.ts: -------------------------------------------------------------------------------- 1 | export * from "./index" -------------------------------------------------------------------------------- /backend/src/generated/prisma/wasm.js: -------------------------------------------------------------------------------- 1 | 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | 4 | const { 5 | Decimal, 6 | objectEnumValues, 7 | makeStrictEnum, 8 | Public, 9 | getRuntime, 10 | skip 11 | } = require('./runtime/index-browser.js') 12 | 13 | 14 | const Prisma = {} 15 | 16 | exports.Prisma = Prisma 17 | exports.$Enums = {} 18 | 19 | /** 20 | * Prisma Client JS version: 6.6.0 21 | * Query Engine version: f676762280b54cd07c770017ed3711ddde35f37a 22 | */ 23 | Prisma.prismaVersion = { 24 | client: "6.6.0", 25 | engine: "f676762280b54cd07c770017ed3711ddde35f37a" 26 | } 27 | 28 | Prisma.PrismaClientKnownRequestError = () => { 29 | const runtimeName = getRuntime().prettyName; 30 | throw new Error(`PrismaClientKnownRequestError is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}). 31 | In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`, 32 | )}; 33 | Prisma.PrismaClientUnknownRequestError = () => { 34 | const runtimeName = getRuntime().prettyName; 35 | throw new Error(`PrismaClientUnknownRequestError is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}). 36 | In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`, 37 | )} 38 | Prisma.PrismaClientRustPanicError = () => { 39 | const runtimeName = getRuntime().prettyName; 40 | throw new Error(`PrismaClientRustPanicError is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}). 41 | In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`, 42 | )} 43 | Prisma.PrismaClientInitializationError = () => { 44 | const runtimeName = getRuntime().prettyName; 45 | throw new Error(`PrismaClientInitializationError is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}). 46 | In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`, 47 | )} 48 | Prisma.PrismaClientValidationError = () => { 49 | const runtimeName = getRuntime().prettyName; 50 | throw new Error(`PrismaClientValidationError is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}). 51 | In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`, 52 | )} 53 | Prisma.Decimal = Decimal 54 | 55 | /** 56 | * Re-export of sql-template-tag 57 | */ 58 | Prisma.sql = () => { 59 | const runtimeName = getRuntime().prettyName; 60 | throw new Error(`sqltag is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}). 61 | In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`, 62 | )} 63 | Prisma.empty = () => { 64 | const runtimeName = getRuntime().prettyName; 65 | throw new Error(`empty is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}). 66 | In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`, 67 | )} 68 | Prisma.join = () => { 69 | const runtimeName = getRuntime().prettyName; 70 | throw new Error(`join is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}). 71 | In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`, 72 | )} 73 | Prisma.raw = () => { 74 | const runtimeName = getRuntime().prettyName; 75 | throw new Error(`raw is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}). 76 | In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`, 77 | )} 78 | Prisma.validator = Public.validator 79 | 80 | /** 81 | * Extensions 82 | */ 83 | Prisma.getExtensionContext = () => { 84 | const runtimeName = getRuntime().prettyName; 85 | throw new Error(`Extensions.getExtensionContext is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}). 86 | In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`, 87 | )} 88 | Prisma.defineExtension = () => { 89 | const runtimeName = getRuntime().prettyName; 90 | throw new Error(`Extensions.defineExtension is unable to run in this browser environment, or has been bundled for the browser (running in ${runtimeName}). 91 | In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report`, 92 | )} 93 | 94 | /** 95 | * Shorthand utilities for JSON filtering 96 | */ 97 | Prisma.DbNull = objectEnumValues.instances.DbNull 98 | Prisma.JsonNull = objectEnumValues.instances.JsonNull 99 | Prisma.AnyNull = objectEnumValues.instances.AnyNull 100 | 101 | Prisma.NullTypes = { 102 | DbNull: objectEnumValues.classes.DbNull, 103 | JsonNull: objectEnumValues.classes.JsonNull, 104 | AnyNull: objectEnumValues.classes.AnyNull 105 | } 106 | 107 | 108 | 109 | /** 110 | * Enums 111 | */ 112 | 113 | exports.Prisma.TransactionIsolationLevel = makeStrictEnum({ 114 | ReadUncommitted: 'ReadUncommitted', 115 | ReadCommitted: 'ReadCommitted', 116 | RepeatableRead: 'RepeatableRead', 117 | Serializable: 'Serializable' 118 | }); 119 | 120 | exports.Prisma.UserScalarFieldEnum = { 121 | id: 'id', 122 | name: 'name', 123 | email: 'email', 124 | image: 'image', 125 | role: 'role', 126 | password: 'password', 127 | createdAt: 'createdAt', 128 | updatedAt: 'updatedAt' 129 | }; 130 | 131 | exports.Prisma.ProblemScalarFieldEnum = { 132 | id: 'id', 133 | title: 'title', 134 | description: 'description', 135 | difficulty: 'difficulty', 136 | tags: 'tags', 137 | userId: 'userId', 138 | examples: 'examples', 139 | constraints: 'constraints', 140 | hints: 'hints', 141 | editorial: 'editorial', 142 | testcases: 'testcases', 143 | codeSnippets: 'codeSnippets', 144 | referenceSolutions: 'referenceSolutions', 145 | createdAt: 'createdAt', 146 | updatedAt: 'updatedAt' 147 | }; 148 | 149 | exports.Prisma.SubmissionScalarFieldEnum = { 150 | id: 'id', 151 | userId: 'userId', 152 | problemId: 'problemId', 153 | sourceCode: 'sourceCode', 154 | language: 'language', 155 | stdin: 'stdin', 156 | stdout: 'stdout', 157 | stderr: 'stderr', 158 | compileOutput: 'compileOutput', 159 | status: 'status', 160 | memory: 'memory', 161 | time: 'time', 162 | createdAt: 'createdAt', 163 | updatedAt: 'updatedAt' 164 | }; 165 | 166 | exports.Prisma.TestCaseResultScalarFieldEnum = { 167 | id: 'id', 168 | submissionId: 'submissionId', 169 | testCase: 'testCase', 170 | passed: 'passed', 171 | stdout: 'stdout', 172 | expected: 'expected', 173 | stderr: 'stderr', 174 | compileOutput: 'compileOutput', 175 | status: 'status', 176 | memory: 'memory', 177 | time: 'time', 178 | createdAt: 'createdAt', 179 | updatedAt: 'updatedAt' 180 | }; 181 | 182 | exports.Prisma.ProblemSolvedScalarFieldEnum = { 183 | id: 'id', 184 | userId: 'userId', 185 | problemId: 'problemId', 186 | createdAt: 'createdAt', 187 | updatedAt: 'updatedAt' 188 | }; 189 | 190 | exports.Prisma.PlaylistScalarFieldEnum = { 191 | id: 'id', 192 | name: 'name', 193 | description: 'description', 194 | userId: 'userId', 195 | createdAt: 'createdAt', 196 | updatedAt: 'updatedAt' 197 | }; 198 | 199 | exports.Prisma.ProblemInPlaylistScalarFieldEnum = { 200 | id: 'id', 201 | playListId: 'playListId', 202 | problemId: 'problemId', 203 | createdAt: 'createdAt', 204 | updatedAt: 'updatedAt' 205 | }; 206 | 207 | exports.Prisma.SortOrder = { 208 | asc: 'asc', 209 | desc: 'desc' 210 | }; 211 | 212 | exports.Prisma.JsonNullValueInput = { 213 | JsonNull: Prisma.JsonNull 214 | }; 215 | 216 | exports.Prisma.QueryMode = { 217 | default: 'default', 218 | insensitive: 'insensitive' 219 | }; 220 | 221 | exports.Prisma.NullsOrder = { 222 | first: 'first', 223 | last: 'last' 224 | }; 225 | 226 | exports.Prisma.JsonNullValueFilter = { 227 | DbNull: Prisma.DbNull, 228 | JsonNull: Prisma.JsonNull, 229 | AnyNull: Prisma.AnyNull 230 | }; 231 | exports.UserRole = exports.$Enums.UserRole = { 232 | ADMIN: 'ADMIN', 233 | USER: 'USER' 234 | }; 235 | 236 | exports.Difficulty = exports.$Enums.Difficulty = { 237 | EASY: 'EASY', 238 | MEDIUM: 'MEDIUM', 239 | HARD: 'HARD' 240 | }; 241 | 242 | exports.Prisma.ModelName = { 243 | User: 'User', 244 | Problem: 'Problem', 245 | Submission: 'Submission', 246 | TestCaseResult: 'TestCaseResult', 247 | ProblemSolved: 'ProblemSolved', 248 | Playlist: 'Playlist', 249 | ProblemInPlaylist: 'ProblemInPlaylist' 250 | }; 251 | 252 | /** 253 | * This is a stub Prisma Client that will error at runtime if called. 254 | */ 255 | class PrismaClient { 256 | constructor() { 257 | return new Proxy(this, { 258 | get(target, prop) { 259 | let message 260 | const runtime = getRuntime() 261 | if (runtime.isEdge) { 262 | message = `PrismaClient is not configured to run in ${runtime.prettyName}. In order to run Prisma Client on edge runtime, either: 263 | - Use Prisma Accelerate: https://pris.ly/d/accelerate 264 | - Use Driver Adapters: https://pris.ly/d/driver-adapters 265 | `; 266 | } else { 267 | message = 'PrismaClient is unable to run in this browser environment, or has been bundled for the browser (running in `' + runtime.prettyName + '`).' 268 | } 269 | 270 | message += ` 271 | If this is unexpected, please open an issue: https://pris.ly/prisma-prisma-bug-report` 272 | 273 | throw new Error(message) 274 | } 275 | }) 276 | } 277 | } 278 | 279 | exports.PrismaClient = PrismaClient 280 | 281 | Object.assign(exports, Prisma) 282 | -------------------------------------------------------------------------------- /backend/src/index.js: -------------------------------------------------------------------------------- 1 | import express from "express"; 2 | import dotenv from "dotenv"; 3 | import cookieParser from "cookie-parser"; 4 | import cors from "cors"; 5 | 6 | import authRoutes from "./routes/auth.routes.js"; 7 | import problemRoutes from "./routes/problem.routes.js"; 8 | import executionRoute from "./routes/executeCode.routes.js"; 9 | import submissionRoutes from "./routes/submission.routes.js"; 10 | import playlistRoutes from "./routes/playlist.routes.js"; 11 | 12 | dotenv.config(); 13 | 14 | const app = express(); 15 | 16 | app.use( 17 | cors({ 18 | origin: "http://localhost:5174", 19 | credentials: true, 20 | }) 21 | ); 22 | app.use(express.json()); 23 | app.use(cookieParser()); 24 | 25 | app.get("/", (req, res) => { 26 | res.send("Hello Guys welcome to leetlab🔥"); 27 | }); 28 | 29 | app.use("/api/v1/auth", authRoutes); 30 | app.use("/api/v1/problems", problemRoutes); 31 | app.use("/api/v1/execute-code", executionRoute); 32 | app.use("/api/v1/submission", submissionRoutes); 33 | 34 | app.use("/api/v1/playlist", playlistRoutes); 35 | 36 | app.listen(process.env.PORT, () => { 37 | console.log("Server is running on port 8081"); 38 | }); 39 | -------------------------------------------------------------------------------- /backend/src/libs/db.js: -------------------------------------------------------------------------------- 1 | import {PrismaClient} from "../generated/prisma/index.js"; 2 | 3 | 4 | const globalForPrisma = globalThis; 5 | 6 | 7 | export const db = globalForPrisma.prisma || new PrismaClient(); 8 | 9 | 10 | if(process.env.NODE_ENV !== "production") globalForPrisma.prisma = db -------------------------------------------------------------------------------- /backend/src/libs/judge0.lib.js: -------------------------------------------------------------------------------- 1 | import axios from "axios" 2 | 3 | export const getJudge0LanguageId = (language)=>{ 4 | const languageMap = { 5 | "PYTHON":71, 6 | "JAVA":62, 7 | "JAVASCRIPT":63, 8 | } 9 | 10 | return languageMap[language.toUpperCase()] 11 | } 12 | 13 | const sleep = (ms)=> new Promise((resolve)=> setTimeout(resolve , ms)) 14 | 15 | export const pollBatchResults = async (tokens)=>{ 16 | while(true){ 17 | 18 | const {data} = await axios.get(`${process.env.JUDGE0_API_URL}/submissions/batch`,{ 19 | params:{ 20 | tokens:tokens.join(","), 21 | base64_encoded:false, 22 | } 23 | }) 24 | 25 | const results = data.submissions; 26 | 27 | const isAllDone = results.every( 28 | (r)=> r.status.id !== 1 && r.status.id !== 2 29 | ) 30 | 31 | if(isAllDone) return results 32 | await sleep(1000) 33 | } 34 | } 35 | 36 | export const submitBatch = async (submissions)=>{ 37 | const {data} = await axios.post(`${process.env.JUDGE0_API_URL}/submissions/batch?base64_encoded=false`,{ 38 | submissions 39 | }) 40 | 41 | 42 | console.log("Submission Results: ", data) 43 | 44 | return data // [{token} , {token} , {token}] 45 | } 46 | 47 | 48 | export function getLanguageName(languageId){ 49 | const LANGUAGE_NAMES = { 50 | 74: "TypeScript", 51 | 63: "JavaScript", 52 | 71: "Python", 53 | 62: "Java", 54 | } 55 | 56 | return LANGUAGE_NAMES[languageId] || "Unknown" 57 | } -------------------------------------------------------------------------------- /backend/src/middleware/auth.middleware.js: -------------------------------------------------------------------------------- 1 | import jwt from "jsonwebtoken"; 2 | import {db} from "../libs/db.js" 3 | 4 | export const authMiddleware = async (req , res , next)=>{ 5 | try { 6 | const token = req.cookies.jwt; 7 | 8 | if(!token){ 9 | return res.status(401).json({ 10 | message:"Unauthorized - No token provided" 11 | }) 12 | } 13 | 14 | let decoded; 15 | 16 | try { 17 | decoded = jwt.verify(token , process.env.JWT_SECRET); 18 | } catch (error) { 19 | return res.status(401).json({ 20 | message:"Unauthorized - Invalid token" 21 | }) 22 | } 23 | 24 | const user = await db.user.findUnique({ 25 | where:{ 26 | id:decoded.id 27 | }, 28 | select:{ 29 | id:true, 30 | image:true, 31 | name:true, 32 | email:true, 33 | role:true 34 | } 35 | }); 36 | 37 | 38 | if(!user){ 39 | return res.status(404).json({message:"User not found"}); 40 | } 41 | 42 | req.user = user; 43 | next(); 44 | 45 | } catch (error) { 46 | console.error("Error authenticating user:", error); 47 | res.status(500).json({message:"Error authenticating user"}); 48 | } 49 | } 50 | 51 | 52 | export const checkAdmin = async(req , res , next)=>{ 53 | try { 54 | const userId = req.user.id; 55 | 56 | const user = await db.user.findUnique({ 57 | where:{ 58 | id:userId 59 | }, 60 | select:{ 61 | role:true 62 | } 63 | }) 64 | 65 | if(!user || user.role !== "ADMIN"){ 66 | return res.status(403).json({ 67 | message:"Access denied - Admins only" 68 | }) 69 | } 70 | 71 | next(); 72 | } catch (error) { 73 | console.error("Error checking admin role:", error); 74 | res.status(500).json({message:"Error checking admin role"}); 75 | } 76 | } -------------------------------------------------------------------------------- /backend/src/routes/auth.routes.js: -------------------------------------------------------------------------------- 1 | import express from "express"; 2 | import { check, login, logout, register } from "../controllers/auth.controller.js"; 3 | import { authMiddleware } from "../middleware/auth.middleware.js"; 4 | 5 | 6 | const authRoutes = express.Router(); 7 | 8 | 9 | authRoutes.post("/register" , register) 10 | 11 | authRoutes.post("/login" , login) 12 | 13 | authRoutes.post("/logout" ,authMiddleware , logout) 14 | 15 | authRoutes.get("/check" ,authMiddleware , check) 16 | 17 | export default authRoutes; 18 | 19 | -------------------------------------------------------------------------------- /backend/src/routes/executeCode.routes.js: -------------------------------------------------------------------------------- 1 | import express from "express"; 2 | import { authMiddleware } from "../middleware/auth.middleware.js"; 3 | import { executeCode } from "../controllers/executeCode.controller.js"; 4 | 5 | 6 | const executionRoute = express.Router(); 7 | 8 | 9 | executionRoute.post("/" , authMiddleware , executeCode) 10 | 11 | 12 | 13 | export default executionRoute; -------------------------------------------------------------------------------- /backend/src/routes/playlist.routes.js: -------------------------------------------------------------------------------- 1 | import express from "express"; 2 | import { authMiddleware } from "../middleware/auth.middleware.js"; 3 | import { addProblemToPlaylist, createPlayList, deletePlayList, getPlayAllListDetails, getPlayListDetails, removeProblemFromPlaylist } from "../controllers/playlist.controller.js"; 4 | 5 | const router = express.Router(); 6 | 7 | router.get("/" , authMiddleware , getPlayAllListDetails) 8 | 9 | router.get("/:playlistId" , authMiddleware , getPlayListDetails) 10 | 11 | router.post("/create-playlist" ,authMiddleware , createPlayList) 12 | 13 | 14 | 15 | router.post('/:playlistId/add-problem' , authMiddleware , addProblemToPlaylist) 16 | 17 | router.delete("/:playlistId" , authMiddleware , deletePlayList) 18 | 19 | router.delete("/:playlistId/remove-problem" , authMiddleware , removeProblemFromPlaylist) 20 | 21 | 22 | export default router; -------------------------------------------------------------------------------- /backend/src/routes/problem.routes.js: -------------------------------------------------------------------------------- 1 | import express from 'express'; 2 | import { authMiddleware, checkAdmin } from '../middleware/auth.middleware.js'; 3 | import { createProblem, deleteProblem, getAllProblems, getAllProblemsSolvedByUser, getProblemById, updateProblem } from '../controllers/problem.controller.js'; 4 | 5 | 6 | const problemRoutes = express.Router(); 7 | 8 | problemRoutes.post("/create-problem" , authMiddleware,checkAdmin , createProblem) 9 | 10 | problemRoutes.get("/get-all-problems" , authMiddleware , getAllProblems); 11 | 12 | problemRoutes.get("/get-problem/:id" , authMiddleware , getProblemById); 13 | 14 | 15 | problemRoutes.put("/update-problem/:id" , authMiddleware , checkAdmin , updateProblem) 16 | 17 | 18 | problemRoutes.delete("/delete-problem/:id" , authMiddleware , checkAdmin , deleteProblem) 19 | 20 | problemRoutes.get("/get-solved-problems" , authMiddleware , getAllProblemsSolvedByUser); 21 | 22 | export default problemRoutes; -------------------------------------------------------------------------------- /backend/src/routes/submission.routes.js: -------------------------------------------------------------------------------- 1 | import express from "express" 2 | import { authMiddleware } from "../middleware/auth.middleware.js"; 3 | import { getAllSubmission, getAllTheSubmissionsForProblem, getSubmissionsForProblem } from "../controllers/submission.controller.js"; 4 | 5 | 6 | const submissionRoutes = express.Router() 7 | 8 | 9 | submissionRoutes.get("/get-all-submissions" , authMiddleware , getAllSubmission); 10 | submissionRoutes.get("/get-submission/:problemId" , authMiddleware , getSubmissionsForProblem) 11 | 12 | submissionRoutes.get("/get-submissions-count/:problemId" , authMiddleware , getAllTheSubmissionsForProblem) 13 | 14 | 15 | export default submissionRoutes; -------------------------------------------------------------------------------- /backend/test.js: -------------------------------------------------------------------------------- 1 | const data = `{ 2 | "title": "Add Two Numbers", 3 | "description": "Given two numbers a and b add them up and return the outout", 4 | "difficulty": "EASY", 5 | "tags": [ 6 | "math", 7 | "operators", 8 | "addition" 9 | ], 10 | "examples": { 11 | "PYTHON": { 12 | "input": "3 7", 13 | "output": "10", 14 | "explanation": "Adding 3 and 7 gives 10." 15 | }, 16 | "JAVASCRIPT": { 17 | "input": "-5 12", 18 | "output": "7", 19 | "explanation": "Adding -5 and 12 gives 7." 20 | } 21 | }, 22 | "constraints": "-10^9 ≤ a, b ≤ 10^9", 23 | "testcases": [ 24 | { 25 | "input": "100 200", 26 | "output": "300" 27 | }, 28 | { 29 | "input": "-500 -600", 30 | "output": "-1100" 31 | }, 32 | { 33 | "input": "0 0", 34 | "output": "0" 35 | } 36 | ], 37 | "codeSnippets": { 38 | "JAVASCRIPT": "const readline = require('readline');\n\nfunction addTwoNumbers(a, b) {\n // Write your code here\n // Return the sum of a and b\n}\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet inputLines = [];\n\nrl.on('line', (line) => {\n inputLines = line.split(' ');\n rl.close();\n}).on('close', () => {\n const a = parseInt(inputLines[0], 10);\n const b = parseInt(inputLines[1], 10);\n console.log(addTwoNumbers(a, b));\n});", 39 | "PYTHON": "def add_two_numbers(a, b):\n # Write your code here\n # Return the sum of a and b\n pass\n\nimport sys\ninput_line = sys.stdin.read()\na, b = map(int, input_line.split())\nprint(add_two_numbers(a, b))", 40 | "JAVA": "import java.util.Scanner;\n\npublic class Main {\n public static int addTwoNumbers(int a, int b) {\n // Write your code here\n // Return the sum of a and b\n return 0;\n }\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int a = sc.nextInt();\n int b = sc.nextInt();\n System.out.println(addTwoNumbers(a, b));\n }\n}" 41 | }, 42 | "referenceSolutions": { 43 | "JAVASCRIPT": "const readline = require('readline');\n\nconst rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout\n});\n\nlet inputLines = [];\n\nrl.on('line', (line) => {\n inputLines = line.split(' ');\n rl.close();\n}).on('close', () => {\n const a = parseInt(inputLines[0], 10);\n const b = parseInt(inputLines[1], 10);\n console.log(a + b);\n});", 44 | "PYTHON": "import sys\ninput_line = sys.stdin.read()\na, b = map(int, input_line.split())\nprint(a + b)", 45 | "JAVA": "import java.util.Scanner;\n\npublic class Main {\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int a = sc.nextInt();\n int b = sc.nextInt();\n System.out.println(a + b);\n }\n}" 46 | } 47 | } 48 | ` 49 | // "12 13" 50 | // const input = fs.readFileSync(0, 'utf-8').trim(); 51 | // const [a, b] = input.split(' ').map(Number); 52 | 53 | `const fs = require('fs');\n\nfunction addTwoNumbers(a, b) {\n // Write your code here\n // Return the sum of a and b\n return a + b;\n}\n\n// Reading input from stdin (using fs to read all input)\nconst input = fs.readFileSync(0, 'utf-8').trim();\nconst [a, b] = input.split(' ').map(Number);\n\nconsole.log(addTwoNumbers(a, b))` 54 | 55 | -------------------------------------------------------------------------------- /frontend/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /frontend/README.md: -------------------------------------------------------------------------------- 1 | # React + Vite 2 | 3 | This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. 4 | 5 | Currently, two official plugins are available: 6 | 7 | - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) for Fast Refresh 8 | - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh 9 | 10 | ## Expanding the ESLint configuration 11 | 12 | If you are developing a production application, we recommend using TypeScript with type-aware lint rules enabled. Check out the [TS template](https://github.com/vitejs/vite/tree/main/packages/create-vite/template-react-ts) for information on how to integrate TypeScript and [`typescript-eslint`](https://typescript-eslint.io) in your project. 13 | -------------------------------------------------------------------------------- /frontend/eslint.config.js: -------------------------------------------------------------------------------- 1 | import js from '@eslint/js' 2 | import globals from 'globals' 3 | import reactHooks from 'eslint-plugin-react-hooks' 4 | import reactRefresh from 'eslint-plugin-react-refresh' 5 | 6 | export default [ 7 | { ignores: ['dist'] }, 8 | { 9 | files: ['**/*.{js,jsx}'], 10 | languageOptions: { 11 | ecmaVersion: 2020, 12 | globals: globals.browser, 13 | parserOptions: { 14 | ecmaVersion: 'latest', 15 | ecmaFeatures: { jsx: true }, 16 | sourceType: 'module', 17 | }, 18 | }, 19 | plugins: { 20 | 'react-hooks': reactHooks, 21 | 'react-refresh': reactRefresh, 22 | }, 23 | rules: { 24 | ...js.configs.recommended.rules, 25 | ...reactHooks.configs.recommended.rules, 26 | 'no-unused-vars': ['error', { varsIgnorePattern: '^[A-Z_]' }], 27 | 'react-refresh/only-export-components': [ 28 | 'warn', 29 | { allowConstantExport: true }, 30 | ], 31 | }, 32 | }, 33 | ] 34 | -------------------------------------------------------------------------------- /frontend/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Vite + React 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /frontend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "frontend", 3 | "private": true, 4 | "version": "0.0.0", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "vite", 8 | "build": "vite build", 9 | "lint": "eslint .", 10 | "preview": "vite preview" 11 | }, 12 | "dependencies": { 13 | "@hookform/resolvers": "^5.0.1", 14 | "@monaco-editor/react": "^4.7.0", 15 | "@tailwindcss/vite": "^4.1.6", 16 | "axios": "^1.9.0", 17 | "daisyui": "^5.0.35", 18 | "lucide-react": "^0.509.0", 19 | "monaco-editor": "^0.52.2", 20 | "react": "^19.1.0", 21 | "react-dom": "^19.1.0", 22 | "react-hook-form": "^7.56.3", 23 | "react-hot-toast": "^2.5.2", 24 | "react-router-dom": "^7.6.0", 25 | "tailwindcss": "^4.1.6", 26 | "zod": "^3.24.4", 27 | "zustand": "^5.0.4" 28 | }, 29 | "devDependencies": { 30 | "@eslint/js": "^9.25.0", 31 | "@types/react": "^19.1.2", 32 | "@types/react-dom": "^19.1.2", 33 | "@vitejs/plugin-react": "^4.4.1", 34 | "eslint": "^9.25.0", 35 | "eslint-plugin-react-hooks": "^5.2.0", 36 | "eslint-plugin-react-refresh": "^0.4.19", 37 | "globals": "^16.0.0", 38 | "vite": "^6.3.5" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /frontend/public/leetlab.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /frontend/public/vite.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /frontend/src/App.jsx: -------------------------------------------------------------------------------- 1 | import React, { useEffect } from "react"; 2 | import { Routes, Route, Navigate } from "react-router-dom"; 3 | import { Toaster } from "react-hot-toast"; 4 | 5 | import HomePage from "./page/HomePage"; 6 | import LoginPage from "./page/LoginPage"; 7 | import SignUpPage from "./page/SignUpPage"; 8 | import { useAuthStore } from "./store/useAuthStore"; 9 | import { Loader } from "lucide-react"; 10 | import Layout from "./layout/Layout"; 11 | import AdminRoute from "./components/AdminRoute"; 12 | import AddProblem from "./page/AddProblem"; 13 | import ProblemPage from "./page/ProblemPage"; 14 | 15 | const App = () => { 16 | const { authUser, checkAuth, isCheckingAuth } = useAuthStore(); 17 | 18 | useEffect(() => { 19 | checkAuth(); 20 | }, [checkAuth]); 21 | 22 | if (isCheckingAuth && !authUser) { 23 | return ( 24 |
25 | 26 |
27 | ); 28 | } 29 | 30 | return ( 31 |
32 | 33 | 34 | }> 35 | : } 38 | /> 39 | 40 | 41 | : } 44 | /> 45 | 46 | : } 49 | /> 50 | 51 | : } 54 | /> 55 | 56 | }> 57 | : } 60 | /> 61 | 62 | 63 |
64 | ); 65 | }; 66 | 67 | export default App; 68 | -------------------------------------------------------------------------------- /frontend/src/assets/react.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /frontend/src/components/AddToPlaylist.jsx: -------------------------------------------------------------------------------- 1 | import React, { useEffect, useState } from 'react'; 2 | import { X, Plus, Loader } from 'lucide-react'; 3 | import { usePlaylistStore } from '../store/usePlaylistStore'; 4 | 5 | const AddToPlaylistModal = ({ isOpen, onClose, problemId }) => { 6 | const { playlists, getAllPlaylists, addProblemToPlaylist, isLoading } = usePlaylistStore(); 7 | const [selectedPlaylist, setSelectedPlaylist] = useState(''); 8 | 9 | useEffect(() => { 10 | if (isOpen) { 11 | getAllPlaylists(); 12 | } 13 | }, [isOpen]); 14 | 15 | const handleSubmit = async (e) => { 16 | e.preventDefault(); 17 | if (!selectedPlaylist) return; 18 | 19 | await addProblemToPlaylist(selectedPlaylist, [problemId]); 20 | onClose(); 21 | }; 22 | 23 | if (!isOpen) return null; 24 | 25 | return ( 26 |
27 |
28 |
29 |

Add to Playlist

30 | 33 |
34 | 35 |
36 |
37 | 40 | 53 |
54 | 55 |
56 | 59 | 67 |
68 |
69 |
70 |
71 | ); 72 | }; 73 | 74 | export default AddToPlaylistModal; -------------------------------------------------------------------------------- /frontend/src/components/AdminRoute.jsx: -------------------------------------------------------------------------------- 1 | import { Navigate, Outlet } from "react-router-dom"; 2 | import { useAuthStore } from "../store/useAuthStore"; 3 | import { Loader } from "lucide-react"; 4 | 5 | const AdminRoute = () => { 6 | const {authUser , isCheckingAuth} = useAuthStore() 7 | 8 | if (isCheckingAuth) { 9 | return
; 10 | } 11 | 12 | if(!authUser || authUser.role !== "ADMIN"){ 13 | return ; 14 | } 15 | 16 | return 17 | } 18 | 19 | export default AdminRoute -------------------------------------------------------------------------------- /frontend/src/components/AuthImagePattern.jsx: -------------------------------------------------------------------------------- 1 | import { Code, Terminal, FileCode, Braces } from "lucide-react" 2 | import { useEffect, useState } from "react" 3 | 4 | 5 | 6 | const CodeBackground = ({ title, subtitle }) => { 7 | const [activeIndex, setActiveIndex] = useState(0) 8 | 9 | // Code snippets to display in the background 10 | const codeSnippets = [ 11 | `function twoSum(nums, target) { 12 | const map = new Map(); 13 | for (let i = 0; i < nums.length; i++) { 14 | const complement = target - nums[i]; 15 | if (map.has(complement)) { 16 | return [map.get(complement), i]; 17 | } 18 | map.set(nums[i], i); 19 | } 20 | return []; 21 | }`, 22 | `class ListNode { 23 | constructor(val = 0, next = null) { 24 | this.val = val; 25 | this.next = next; 26 | } 27 | } 28 | 29 | function reverseList(head) { 30 | let prev = null; 31 | let current = head; 32 | while (current) { 33 | const next = current.next; 34 | current.next = prev; 35 | prev = current; 36 | current = next; 37 | } 38 | return prev; 39 | }`, 40 | `function isValid(s) { 41 | const stack = []; 42 | const map = { 43 | '(': ')', 44 | '{': '}', 45 | '[': ']' 46 | }; 47 | 48 | for (let i = 0; i < s.length; i++) { 49 | if (s[i] in map) { 50 | stack.push(s[i]); 51 | } else { 52 | const last = stack.pop(); 53 | if (map[last] !== s[i]) return false; 54 | } 55 | } 56 | 57 | return stack.length === 0; 58 | }`, 59 | ] 60 | 61 | // Rotate through code snippets 62 | useEffect(() => { 63 | const interval = setInterval(() => { 64 | setActiveIndex((prev) => (prev + 1) % codeSnippets.length) 65 | }, 2000) 66 | return () => clearInterval(interval) 67 | }, [codeSnippets.length]) 68 | 69 | return ( 70 |
71 | {/* Animated code symbols in background */} 72 |
73 |
74 | 75 |
76 |
77 | 78 |
79 |
80 | 81 |
82 |
83 | 84 |
85 |
86 | 87 |
88 |
89 | 90 |
91 |
92 | 93 |
94 | {/* Code editor mockup */} 95 |
96 | {/* Editor header */} 97 |
98 |
99 |
100 |
101 |
102 |
103 |
problem.js
104 |
105 | 106 | {/* Code content */} 107 |
108 |
109 |               {codeSnippets[activeIndex]}
110 |             
111 | 112 | {/* Blinking cursor */} 113 |
114 |
115 |
116 | 117 | {/* Logo */} 118 |
119 |
120 | 121 |
122 |
123 | 124 | {/* Text content */} 125 |

{title}

126 |

{subtitle}

127 |
128 |
129 | ) 130 | } 131 | 132 | export default CodeBackground 133 | -------------------------------------------------------------------------------- /frontend/src/components/CreatePlaylistModal.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import {useForm} from "react-hook-form"; 3 | import {X} from "lucide-react"; 4 | const CreatePlaylistModal = ({isOpen , onClose , onSubmit}) => { 5 | const {register , handleSubmit , formState:{errors} , reset} = useForm(); 6 | 7 | const handleFormSubmit = async (data)=>{ 8 | await onSubmit(data); 9 | reset() 10 | onClose() 11 | } 12 | 13 | if(!isOpen) return null; 14 | 15 | return ( 16 |
17 |
18 |
19 |

Create New Playlist

20 | 23 |
24 | 25 |
26 |
27 | 30 | 36 | {errors.name && ( 37 | 40 | )} 41 |
42 | 43 |
44 | 47 |