From 989fd441e3b921395ae70dc58fbbb7f679042c89 Mon Sep 17 00:00:00 2001 From: tarun-baranwal Date: Fri, 27 Feb 2026 00:08:10 +0530 Subject: [PATCH 1/9] Add new --- package-lock.json | 1 - prisma/schema.prisma | 200 ++++++++++++++-------------- src/app.js | 3 +- src/controllers/admin.controller.js | 14 ++ src/routes/admin.routes.js | 9 ++ src/services/admin.service.js | 34 +++++ src/services/auth.service.js | 75 +++++------ 7 files changed, 190 insertions(+), 146 deletions(-) create mode 100644 src/controllers/admin.controller.js create mode 100644 src/routes/admin.routes.js create mode 100644 src/services/admin.service.js diff --git a/package-lock.json b/package-lock.json index 653889e..c8e169c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,7 +20,6 @@ "jsonwebtoken": "^9.0.2", "node-cron": "^3.0.3", "nodemailer": "^8.0.1", - "prisma": "^5.8.0", "prisma": "^5.22.0", "winston": "^3.11.0" }, diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 24667b0..be7d5c7 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -1,6 +1,3 @@ -// This is your Prisma schema file, -// learn more about it in the docs: https://pris.ly/d/prisma-schema - generator client { provider = "prisma-client-js" } @@ -10,97 +7,97 @@ datasource db { url = env("DATABASE_URL") } +model DailySubmission { + id String @id @default(uuid()) + userId String + challengeId String + date DateTime + total Int + passed Int + failed Int + + user User @relation(fields: [userId], references: [id], name: "UserDailySubmissions") + challenge Challenge @relation(fields: [challengeId], references: [id], name: "ChallengeDailySubmissions") + + @@index([challengeId, date]) + @@map("daily_submissions") +} + model User { - id String @id @default(uuid()) - email String @unique - username String @unique - password String - leetcodeUsername String? - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - - // Email Preferences - emailPreferences Json? @default("{\"welcomeEmail\": true, \"streakReminder\": true, \"streakBroken\": true, \"weeklySummary\": true}") - + id String @id @default(uuid()) + email String @unique + username String @unique + password String + leetcodeUsername String? + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + // Relations - ownedChallenges Challenge[] @relation("ChallengeOwner") - memberships ChallengeMember[] - + dailySubmissions DailySubmission[] @relation("UserDailySubmissions") + ownedChallenges Challenge[] @relation("ChallengeOwner") + memberships ChallengeMember[] + @@map("users") } model Challenge { - id String @id @default(uuid()) - name String - description String? - ownerId String - - // Challenge Rules - minSubmissionsPerDay Int @default(1) - difficultyFilter String[] // ["Easy", "Medium", "Hard"] - uniqueProblemConstraint Boolean @default(true) - penaltyAmount Float @default(0) - - // Challenge Timeline - startDate DateTime - endDate DateTime - status ChallengeStatus @default(PENDING) - visibility ChallengeVisibility @default(PUBLIC) - - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - + id String @id @default(uuid()) + name String + description String? + ownerId String + startDate DateTime + endDate DateTime + status ChallengeStatus @default(PENDING) + visibility ChallengeVisibility @default(PUBLIC) + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + // Relations - owner User @relation("ChallengeOwner", fields: [ownerId], references: [id], onDelete: Cascade) - members ChallengeMember[] - dailyResults DailyResult[] - + owner User @relation("ChallengeOwner", fields: [ownerId], references: [id], onDelete: Cascade) + dailySubmissions DailySubmission[] @relation("ChallengeDailySubmissions") + members ChallengeMember[] + @@map("challenges") } model ChallengeMember { - id String @id @default(uuid()) - challengeId String - userId String - joinedAt DateTime @default(now()) - isActive Boolean @default(true) - - // Computed Stats - currentStreak Int @default(0) - longestStreak Int @default(0) - totalPenalties Float @default(0) - + id String @id @default(uuid()) + challengeId String + userId String + joinedAt DateTime @default(now()) + isActive Boolean @default(true) + + // Stats + currentStreak Int @default(0) + longestStreak Int @default(0) + totalPenalties Float @default(0) + // Relations - challenge Challenge @relation(fields: [challengeId], references: [id], onDelete: Cascade) - user User @relation(fields: [userId], references: [id], onDelete: Cascade) - dailyResults DailyResult[] - penaltyLedger PenaltyLedger[] - + challenge Challenge @relation(fields: [challengeId], references: [id], onDelete: Cascade) + user User @relation(fields: [userId], references: [id], onDelete: Cascade) + dailyResults DailyResult[] + penaltyLedger PenaltyLedger[] + @@unique([challengeId, userId]) @@map("challenge_members") } model DailyResult { - id String @id @default(uuid()) - challengeId String - memberId String - date DateTime @db.Date - - // Evaluation Results - completed Boolean @default(false) - submissionsCount Int @default(0) - problemsSolved String[] // Array of problem slugs - - // Metadata - evaluatedAt DateTime? - metadata Json? // Store additional data like submission details - - createdAt DateTime @default(now()) - + id String @id @default(uuid()) + challengeId String + memberId String + date DateTime @db.Date + completed Boolean @default(false) + submissionsCount Int @default(0) + problemsSolved String[] + evaluatedAt DateTime? + metadata Json? + createdAt DateTime @default(now()) + // Relations - challenge Challenge @relation(fields: [challengeId], references: [id], onDelete: Cascade) - member ChallengeMember @relation(fields: [memberId], references: [id], onDelete: Cascade) - + challenge Challenge @relation(fields: [challengeId], references: [id], onDelete: Cascade) + member ChallengeMember @relation(fields: [memberId], references: [id], onDelete: Cascade) + @@unique([challengeId, memberId, date]) @@index([date]) @@index([memberId]) @@ -108,38 +105,35 @@ model DailyResult { } model PenaltyLedger { - id String @id @default(uuid()) - memberId String - amount Float - reason String - date DateTime @db.Date - createdAt DateTime @default(now()) - - // Relations - member ChallengeMember @relation(fields: [memberId], references: [id], onDelete: Cascade) - + id String @id @default(uuid()) + memberId String + amount Float + reason String + date DateTime @db.Date + createdAt DateTime @default(now()) + + member ChallengeMember @relation(fields: [memberId], references: [id], onDelete: Cascade) + @@index([memberId]) @@index([date]) @@map("penalty_ledger") } model ProblemMetadata { - id String @id @default(uuid()) - titleSlug String @unique - questionId String - title String - difficulty String // Easy, Medium, Hard - acRate Float? - likes Int? - dislikes Int? - isPaidOnly Boolean @default(false) - topicTags String[] // Array of topic names - - // Cache metadata - lastFetchedAt DateTime @default(now()) - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - + id String @id @default(uuid()) + titleSlug String @unique + questionId String + title String + difficulty String + acRate Float? + likes Int? + dislikes Int? + isPaidOnly Boolean @default(false) + topicTags String[] + lastFetchedAt DateTime @default(now()) + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + @@index([titleSlug]) @@index([difficulty]) @@map("problem_metadata") @@ -155,4 +149,4 @@ enum ChallengeStatus { enum ChallengeVisibility { PUBLIC PRIVATE -} +} \ No newline at end of file diff --git a/src/app.js b/src/app.js index 45ac8c4..6b0e7ed 100644 --- a/src/app.js +++ b/src/app.js @@ -3,6 +3,7 @@ const cors = require("cors"); const { config } = require("./config/env"); const { errorHandler, notFound } = require("./middlewares/error.middleware"); const logger = require("./utils/logger"); +const adminRoutes = require("./routes/admin.routes"); // Import routes const authRoutes = require("./routes/auth.routes"); @@ -23,7 +24,7 @@ const createApp = () => { // Apply strict limiting specifically to auth routes app.use('/api/auth/', authLimiter); - + app.use("/api/admin", adminRoutes); // 2. CORS configuration app.use( cors({ diff --git a/src/controllers/admin.controller.js b/src/controllers/admin.controller.js new file mode 100644 index 0000000..f39de56 --- /dev/null +++ b/src/controllers/admin.controller.js @@ -0,0 +1,14 @@ +const { asyncHandler } = require("../middlewares/error.middleware"); +const { getSubmissionAnalytics } = require("../services/admin.service"); + +const analyticsDashboard = asyncHandler(async (req, res) => { + const analytics = await getSubmissionAnalytics(); + + res.status(200).json({ + success: true, + message: "Admin submission analytics", + data: analytics, + }); +}); + +module.exports = { analyticsDashboard }; \ No newline at end of file diff --git a/src/routes/admin.routes.js b/src/routes/admin.routes.js new file mode 100644 index 0000000..a437ef0 --- /dev/null +++ b/src/routes/admin.routes.js @@ -0,0 +1,9 @@ +const express = require("express"); +const router = express.Router(); +const { analyticsDashboard } = require("../controllers/admin.controller"); +const { authenticate, authorizeAdmin } = require("../middlewares/auth.middleware"); + +// Only admin can access +router.get("/analytics", authenticate, authorizeAdmin, analyticsDashboard); + +module.exports = router; \ No newline at end of file diff --git a/src/services/admin.service.js b/src/services/admin.service.js new file mode 100644 index 0000000..207a8ce --- /dev/null +++ b/src/services/admin.service.js @@ -0,0 +1,34 @@ +const { prisma } = require("../config/prisma"); + +const getSubmissionAnalytics = async () => { + // Submissions per day + const submissionsPerDay = await prisma.dailySubmission.groupBy({ + by: ["date"], + _sum: { total: true }, + orderBy: { date: "asc" }, + }); + + // Pass/fail rate per challenge + const passFailRate = await prisma.dailySubmission.groupBy({ + by: ["challengeId"], + _sum: { passed: true, failed: true, total: true }, + }); + + // Challenges with highest fail rates + const failRates = passFailRate + .map((c) => ({ + challengeId: c.challengeId, + failRate: c._sum.failed / c._sum.total, + totalSubmissions: c._sum.total, + })) + .sort((a, b) => b.failRate - a.failRate) + .slice(0, 5); // top 5 challenges + + return { + submissionsPerDay, + passFailRate, + highestFailChallenges: failRates, + }; +}; + +module.exports = { getSubmissionAnalytics }; \ No newline at end of file diff --git a/src/services/auth.service.js b/src/services/auth.service.js index be998fc..2fa22f7 100644 --- a/src/services/auth.service.js +++ b/src/services/auth.service.js @@ -7,8 +7,6 @@ const { sendWelcomeEmail } = require("./email.service"); /** * Register a new user - * @param {Object} userData - User registration data - * @returns {Object} User object and JWT token */ const register = async (userData) => { const { email, username, password, leetcodeUsername } = userData; @@ -40,13 +38,6 @@ const register = async (userData) => { password: hashedPassword, leetcodeUsername: leetcodeUsername || null, }, - select: { - id: true, - email: true, - username: true, - leetcodeUsername: true, - createdAt: true, - }, }); // Generate JWT token @@ -60,22 +51,28 @@ const register = async (userData) => { }); return { - user, + user: { + id: user.id, + email: user.email, + username: user.username, + leetcodeUsername: user.leetcodeUsername, + createdAt: user.createdAt, + }, token, }; }; /** * Login user - * @param {string} emailOrUsername - Email or username - * @param {string} password - User password - * @returns {Object} User object and JWT token */ const login = async (emailOrUsername, password) => { - // Find user by email or username + // Find user by email OR username const user = await prisma.user.findFirst({ where: { - OR: [{ email: emailOrUsername }, { username: emailOrUsername }], + OR: [ + { email: emailOrUsername }, + { username: emailOrUsername }, + ], }, }); @@ -83,14 +80,14 @@ const login = async (emailOrUsername, password) => { throw new AppError("Invalid credentials", 401); } - // Verify password + // Compare password const isPasswordValid = await bcrypt.compare(password, user.password); if (!isPasswordValid) { throw new AppError("Invalid credentials", 401); } - // Generate JWT token + // Generate token const token = generateToken({ userId: user.id }); logger.info(`User logged in: ${user.username}`); @@ -109,8 +106,6 @@ const login = async (emailOrUsername, password) => { /** * Get user profile - * @param {string} userId - User ID - * @returns {Object} User profile */ const getProfile = async (userId) => { const user = await prisma.user.findUnique({ @@ -139,14 +134,11 @@ const getProfile = async (userId) => { /** * Update user profile - * @param {string} userId - User ID - * @param {Object} updateData - Data to update - * @returns {Object} Updated user profile */ const updateProfile = async (userId, updateData) => { const { leetcodeUsername, currentPassword, newPassword } = updateData; - // If changing password, verify current password + // If password change requested if (newPassword) { if (!currentPassword) { throw new AppError("Current password is required", 400); @@ -156,6 +148,10 @@ const updateProfile = async (userId, updateData) => { where: { id: userId }, }); + if (!user) { + throw new AppError("User not found", 404); + } + const isPasswordValid = await bcrypt.compare( currentPassword, user.password @@ -165,7 +161,6 @@ const updateProfile = async (userId, updateData) => { throw new AppError("Current password is incorrect", 401); } - // Hash new password const hashedPassword = await bcrypt.hash(newPassword, 12); const updatedUser = await prisma.user.update({ @@ -175,18 +170,17 @@ const updateProfile = async (userId, updateData) => { leetcodeUsername: leetcodeUsername !== undefined ? leetcodeUsername : undefined, }, - select: { - id: true, - email: true, - username: true, - leetcodeUsername: true, - updatedAt: true, - }, }); logger.info(`User profile updated: ${updatedUser.username}`); - return updatedUser; + return { + id: updatedUser.id, + email: updatedUser.email, + username: updatedUser.username, + leetcodeUsername: updatedUser.leetcodeUsername, + updatedAt: updatedUser.updatedAt, + }; } // Update without password change @@ -196,18 +190,17 @@ const updateProfile = async (userId, updateData) => { leetcodeUsername: leetcodeUsername !== undefined ? leetcodeUsername : undefined, }, - select: { - id: true, - email: true, - username: true, - leetcodeUsername: true, - updatedAt: true, - }, }); logger.info(`User profile updated: ${updatedUser.username}`); - return updatedUser; + return { + id: updatedUser.id, + email: updatedUser.email, + username: updatedUser.username, + leetcodeUsername: updatedUser.leetcodeUsername, + updatedAt: updatedUser.updatedAt, + }; }; module.exports = { @@ -215,4 +208,4 @@ module.exports = { login, getProfile, updateProfile, -}; +}; \ No newline at end of file From 6c9420f53af3ca6bc13b5e48b05ed73ec2f4ddfc Mon Sep 17 00:00:00 2001 From: Deep Patel Date: Tue, 24 Feb 2026 23:22:54 +0530 Subject: [PATCH 2/9] feat: Implement password reset functionality with email notifications --- README.md | 4 + prisma/schema.prisma | 14 ++++ src/config/env.js | 3 + src/controllers/auth.controller.js | 70 ++++++++++++++++++ src/routes/auth.routes.js | 22 ++++++ src/services/auth.service.js | 115 ++++++++++++++++++++++++++++- src/services/email.service.js | 76 +++++++++++++++++++ 7 files changed, 302 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 30eb359..e92f4e4 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,8 @@ src/ - `DATABASE_URL`: PostgreSQL connection string - `JWT_SECRET`: Generate with `node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"` - `ENCRYPTION_KEY`: Generate with `node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"` + - `APP_BASE_URL`: Frontend/base URL used in password reset links (e.g. `http://localhost:5173`) + - `PASSWORD_RESET_TOKEN_EXPIRY_MINUTES`: Reset token validity window in minutes (default: `60`) - Other configuration as needed 4. **Set up database** @@ -121,6 +123,8 @@ The server will start on `http://localhost:3000` (or the port specified in `.env - `POST /api/auth/register` - Register new user - `POST /api/auth/login` - Login user +- `POST /api/auth/forgot-password` - Request password reset link +- `POST /api/auth/reset-password` - Reset password with token - `GET /api/auth/profile` - Get current user profile (protected) - `PUT /api/auth/profile` - Update user profile (protected) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index be7d5c7..a607506 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -32,6 +32,20 @@ model User { createdAt DateTime @default(now()) updatedAt DateTime @updatedAt + id String @id @default(uuid()) + email String @unique + username String @unique + password String + passwordResetTokenHash String? + passwordResetTokenExpiry DateTime? + leetcodeUsername String? + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + + // Email Preferences + emailPreferences Json? @default("{\"welcomeEmail\": true, \"streakReminder\": true, \"streakBroken\": true, \"weeklySummary\": true}") + + // Relations dailySubmissions DailySubmission[] @relation("UserDailySubmissions") ownedChallenges Challenge[] @relation("ChallengeOwner") diff --git a/src/config/env.js b/src/config/env.js index 9e0844b..fb1c5d4 100644 --- a/src/config/env.js +++ b/src/config/env.js @@ -43,6 +43,9 @@ const config = { smtpPass: process.env.SMTP_PASS, emailFrom: process.env.EMAIL_FROM || "Code Duel ", emailEnabled: process.env.EMAIL_ENABLED === "true", + appBaseUrl: process.env.APP_BASE_URL || "http://localhost:3000", + passwordResetTokenExpiryMinutes: + parseInt(process.env.PASSWORD_RESET_TOKEN_EXPIRY_MINUTES, 10) || 60, // CORS Configuration corsOrigin: process.env.CORS_ORIGIN || "*", diff --git a/src/controllers/auth.controller.js b/src/controllers/auth.controller.js index cd52a0b..b337dea 100644 --- a/src/controllers/auth.controller.js +++ b/src/controllers/auth.controller.js @@ -35,6 +35,26 @@ const validateLogin = [ body("password").notEmpty().withMessage("Password is required"), ]; +/** + * Validation middleware for forgot password + */ +const validateForgotPassword = [ + body("email") + .isEmail() + .normalizeEmail() + .withMessage("Valid email is required"), +]; + +/** + * Validation middleware for reset password + */ +const validateResetPassword = [ + body("token").notEmpty().withMessage("Reset token is required"), + body("newPassword") + .isLength({ min: 6 }) + .withMessage("New password must be at least 6 characters"), +]; + /** * Register a new user * POST /api/auth/register @@ -125,6 +145,52 @@ const updateProfile = asyncHandler(async (req, res) => { }); }); +/** + * Request password reset + * POST /api/auth/forgot-password + */ +const forgotPassword = asyncHandler(async (req, res) => { + const errors = validationResult(req); + if (!errors.isEmpty()) { + return res.status(400).json({ + success: false, + message: "Validation failed", + errors: errors.array(), + }); + } + + const { email } = req.body; + const result = await authService.forgotPassword(email); + + res.status(200).json({ + success: true, + message: result.message, + }); +}); + +/** + * Reset password using token + * POST /api/auth/reset-password + */ +const resetPassword = asyncHandler(async (req, res) => { + const errors = validationResult(req); + if (!errors.isEmpty()) { + return res.status(400).json({ + success: false, + message: "Validation failed", + errors: errors.array(), + }); + } + + const { token, newPassword } = req.body; + const result = await authService.resetPassword(token, newPassword); + + res.status(200).json({ + success: true, + message: result.message, + }); +}); + module.exports = { register, login, @@ -132,4 +198,8 @@ module.exports = { updateProfile, validateRegister, validateLogin, + forgotPassword, + resetPassword, + validateForgotPassword, + validateResetPassword, }; diff --git a/src/routes/auth.routes.js b/src/routes/auth.routes.js index f7ace29..ca736c1 100644 --- a/src/routes/auth.routes.js +++ b/src/routes/auth.routes.js @@ -21,6 +21,28 @@ router.post( */ router.post("/login", authController.validateLogin, authController.login); +/** + * @route POST /api/auth/forgot-password + * @desc Request a password reset link + * @access Public + */ +router.post( + "/forgot-password", + authController.validateForgotPassword, + authController.forgotPassword +); + +/** + * @route POST /api/auth/reset-password + * @desc Reset password using a valid reset token + * @access Public + */ +router.post( + "/reset-password", + authController.validateResetPassword, + authController.resetPassword +); + /** * @route GET /api/auth/profile * @desc Get current user profile diff --git a/src/services/auth.service.js b/src/services/auth.service.js index 2fa22f7..5248e21 100644 --- a/src/services/auth.service.js +++ b/src/services/auth.service.js @@ -1,9 +1,11 @@ const bcrypt = require("bcryptjs"); +const crypto = require("crypto"); const { prisma } = require("../config/prisma"); +const { config } = require("../config/env"); const { generateToken } = require("../utils/jwt"); const { AppError } = require("../middlewares/error.middleware"); const logger = require("../utils/logger"); -const { sendWelcomeEmail } = require("./email.service"); +const { sendWelcomeEmail, sendPasswordResetEmail } = require("./email.service"); /** * Register a new user @@ -203,9 +205,118 @@ const updateProfile = async (userId, updateData) => { }; }; +/** + * Request password reset email + * @param {string} email - User email + * @returns {Object} Generic response + */ +const forgotPassword = async (email) => { + const user = await prisma.user.findUnique({ + where: { email }, + select: { + id: true, + email: true, + username: true, + }, + }); + + if (!user) { + logger.info(`Password reset requested for non-existent email: ${email}`); + return { + message: + "If an account with that email exists, a password reset link has been sent.", + }; + } + + const rawToken = crypto.randomBytes(32).toString("hex"); + const tokenHash = crypto.createHash("sha256").update(rawToken).digest("hex"); + const expiryDate = new Date( + Date.now() + config.passwordResetTokenExpiryMinutes * 60 * 1000 + ); + + await prisma.user.update({ + where: { id: user.id }, + data: { + passwordResetTokenHash: tokenHash, + passwordResetTokenExpiry: expiryDate, + }, + }); + + const resetLink = `${config.appBaseUrl}/reset-password?token=${rawToken}`; + + const emailResult = await sendPasswordResetEmail( + user.email, + user.username, + resetLink, + config.passwordResetTokenExpiryMinutes + ); + + if (!emailResult.success) { + logger.error( + `Password reset email failed for ${user.email}: ${emailResult.reason}` + ); + } + + return { + message: + "If an account with that email exists, a password reset link has been sent.", + }; +}; + +/** + * Reset user password using token + * @param {string} token - Raw reset token + * @param {string} newPassword - New password + * @returns {Object} Success message + */ +const resetPassword = async (token, newPassword) => { + const tokenHash = crypto.createHash("sha256").update(token).digest("hex"); + + const user = await prisma.user.findFirst({ + where: { + passwordResetTokenHash: tokenHash, + passwordResetTokenExpiry: { + gt: new Date(), + }, + }, + select: { + id: true, + username: true, + }, + }); + + if (!user) { + throw new AppError("Invalid or expired reset token", 400); + } + + const hashedPassword = await bcrypt.hash(newPassword, 12); + + await prisma.user.update({ + where: { id: user.id }, + data: { + password: hashedPassword, + passwordResetTokenHash: null, + passwordResetTokenExpiry: null, + }, + }); + + logger.info(`Password reset successful for user: ${user.username}`); + + return { + message: "Password reset successful", + }; +}; + module.exports = { register, login, getProfile, updateProfile, -}; \ No newline at end of file + +}; + + forgotPassword, + resetPassword, + +}; + diff --git a/src/services/email.service.js b/src/services/email.service.js index 1b176eb..e3bade1 100644 --- a/src/services/email.service.js +++ b/src/services/email.service.js @@ -259,6 +259,54 @@ const templates = { `, }), + + /** + * Password reset template + */ + passwordReset: (username, resetLink, expiryMinutes) => ({ + subject: "Reset your Code Duel password", + html: ` + + + + + + +
+
+

Password Reset Request

+
+
+

Hi ${username},

+

We received a request to reset your password for your Code Duel account.

+

+ Reset Password +

+

If the button does not work, use this link:

+

${resetLink}

+
+ Security notice: This link expires in ${expiryMinutes} minutes and can be used only once. +
+

If you did not request this change, you can safely ignore this email.

+

The Code Duel Team

+
+ +
+ + + `, + }), }; /** @@ -362,6 +410,33 @@ const sendWeeklySummary = async (email, username, stats) => { } }; +/** + * Send password reset email + * @param {string} email - User email + * @param {string} username - Username + * @param {string} resetLink - Reset URL + * @param {number} expiryMinutes - Expiry in minutes + */ +const sendPasswordResetEmail = async (email, username, resetLink, expiryMinutes) => { + try { + const template = templates.passwordReset(username, resetLink, expiryMinutes); + const result = await sendEmail({ + to: email, + subject: template.subject, + html: template.html, + }); + + if (result.success) { + logger.info(`Password reset email sent to ${email}`); + } + + return result; + } catch (error) { + logger.error(`Failed to send password reset email to ${email}:`, error); + return { success: false, reason: error.message }; + } +}; + /** * Send daily reminder to users who haven't completed today's challenge */ @@ -565,6 +640,7 @@ const getLeaderboardRank = async (challengeId, memberId) => { module.exports = { sendWelcomeEmail, + sendPasswordResetEmail, sendStreakReminder, sendStreakBrokenNotification, sendWeeklySummary, From 7fdfd44d5b16b4cc49d7e3ca93070338df108542 Mon Sep 17 00:00:00 2001 From: Aryan Parikh Date: Mon, 23 Feb 2026 22:42:32 +0530 Subject: [PATCH 3/9] refactor: eliminate N+1 queries in dashboard endpoints using bulk service methods - Replace per-membership prisma.dailyResult loops in getDashboard and getTodayStatus with two bulk queries using memberId: { in: memberIds } - Add getBulkTodayResults() and getBulkMemberDailyResults() service methods that fetch all results in one query and return maps keyed by memberId - Add normaliseToMidnight() helper to centralise date normalisation logic - Group results in-memory via reduce for O(1) controller-level lookup - Add normaliseToMidnight() helper to centralise date normalisation logic - Fixes 30+ DB queries per request (15 challenges) down to 3 queries for getDashboard and 2 for getTodayStatus Closes #21 --- src/controllers/dashboard.controller.js | 134 ++++++++++++------------ src/services/evaluation.service.js | 74 +++++++++++++ 2 files changed, 139 insertions(+), 69 deletions(-) diff --git a/src/controllers/dashboard.controller.js b/src/controllers/dashboard.controller.js index 1e32004..684d760 100644 --- a/src/controllers/dashboard.controller.js +++ b/src/controllers/dashboard.controller.js @@ -34,49 +34,44 @@ const getDashboard = asyncHandler(async (req, res) => { }, }); - // Get today's status for each membership - const today = new Date(); - today.setHours(0, 0, 0, 0); + if (memberships.length === 0) { + return res.status(200).json({ success: true, data: [] }); + } - const dashboardData = await Promise.all( - memberships.map(async (membership) => { - // Get today's result - const todayResult = await prisma.dailyResult.findUnique({ - where: { - challengeId_memberId_date: { - challengeId: membership.challengeId, - memberId: membership.id, - date: today, - }, - }, - }); + const memberIds = memberships.map((m) => m.id); - // Get recent daily results (last 7 days) - const recentResults = await evaluationService.getMemberDailyResults( - membership.id, - 7 - ); + // Delegate all bulk fetching and grouping to the service layer. + // getBulkMemberDailyResults uses a 7-calendar-day window (not take:7) so + // that missing days are correctly represented as absent entries in the + // activity strip rather than being silently skipped. + const [todayResultByMember, recentResultsByMember] = await Promise.all([ + evaluationService.getBulkTodayResults(memberIds), + evaluationService.getBulkMemberDailyResults(memberIds, 7), + ]); - return { - challenge: membership.challenge, - currentStreak: membership.currentStreak, - longestStreak: membership.longestStreak, - totalPenalties: membership.totalPenalties, - todayStatus: todayResult - ? { - completed: todayResult.completed, - submissionsCount: todayResult.submissionsCount, - evaluatedAt: todayResult.evaluatedAt, - } - : null, - recentResults: recentResults.map((r) => ({ - date: r.date, - completed: r.completed, - submissionsCount: r.submissionsCount, - })), - }; - }) - ); + const dashboardData = memberships.map((membership) => { + const todayResult = todayResultByMember[membership.id] || null; + const memberRecentResults = recentResultsByMember[membership.id] || []; + + return { + challenge: membership.challenge, + currentStreak: membership.currentStreak, + longestStreak: membership.longestStreak, + totalPenalties: membership.totalPenalties, + todayStatus: todayResult + ? { + completed: todayResult.completed, + submissionsCount: todayResult.submissionsCount, + evaluatedAt: todayResult.evaluatedAt, + } + : null, + recentResults: memberRecentResults.map((r) => ({ + date: r.date, + completed: r.completed, + submissionsCount: r.submissionsCount, + })), + }; + }); res.status(200).json({ success: true, @@ -224,8 +219,6 @@ const getChallengeLeaderboard = asyncHandler(async (req, res) => { */ const getTodayStatus = asyncHandler(async (req, res) => { const userId = req.user.id; - const today = new Date(); - today.setHours(0, 0, 0, 0); // Get all active memberships const memberships = await prisma.challengeMember.findMany({ @@ -247,34 +240,37 @@ const getTodayStatus = asyncHandler(async (req, res) => { }, }); - // Get today's results - const todayStatuses = await Promise.all( - memberships.map(async (membership) => { - const result = await prisma.dailyResult.findUnique({ - where: { - challengeId_memberId_date: { - challengeId: membership.challengeId, - memberId: membership.id, - date: today, - }, - }, - }); + const today = new Date(); + today.setHours(0, 0, 0, 0); - return { - challengeId: membership.challenge.id, - challengeName: membership.challenge.name, - requiredSubmissions: membership.challenge.minSubmissionsPerDay, - status: result - ? { - completed: result.completed, - submissionsCount: result.submissionsCount, - problemsSolved: result.problemsSolved, - evaluatedAt: result.evaluatedAt, - } - : null, - }; - }) - ); + if (memberships.length === 0) { + return res.status(200).json({ + success: true, + data: { date: today, challenges: [] }, + }); + } + + const memberIds = memberships.map((m) => m.id); + + // Delegate bulk fetching and grouping to the service layer + const resultByMemberId = await evaluationService.getBulkTodayResults(memberIds); + + const todayStatuses = memberships.map((membership) => { + const result = resultByMemberId[membership.id] || null; + return { + challengeId: membership.challenge.id, + challengeName: membership.challenge.name, + requiredSubmissions: membership.challenge.minSubmissionsPerDay, + status: result + ? { + completed: result.completed, + submissionsCount: result.submissionsCount, + problemsSolved: result.problemsSolved, + evaluatedAt: result.evaluatedAt, + } + : null, + }; + }); res.status(200).json({ success: true, diff --git a/src/services/evaluation.service.js b/src/services/evaluation.service.js index ced9e30..9bf93ed 100644 --- a/src/services/evaluation.service.js +++ b/src/services/evaluation.service.js @@ -316,6 +316,78 @@ const getMemberDailyResults = async (memberId, limit = 30) => { }); }; +/** + * Normalise a Date to local midnight so all date comparisons are consistent. + * Uses local time to match the convention used throughout the codebase + * (stats.service.js, dashboard.controller.js, cron evaluation). + * @param {Date} [date=new Date()] - Date to normalise (defaults to now) + * @returns {Date} Normalised date at 00:00:00.000 local time + */ +const normaliseToMidnight = (date = new Date()) => { + const d = new Date(date); + d.setHours(0, 0, 0, 0); + return d; +}; + +/** + * Get daily results for multiple members in a single bulk query. + * Results are returned grouped by memberId to avoid N+1 query patterns. + * + * The window is intentionally calendar-based (e.g. daysBack=7 means the last + * 7 calendar days including today). This is the correct semantic for dashboard + * activity strips where missing days are meaningful — they represent days on + * which the member did not submit. Using a record-count limit (take: N) would + * silently skip missed days and surface stale results from weeks ago. + * + * @param {string[]} memberIds - Array of challenge member IDs + * @param {number} daysBack - Number of calendar days to look back (default 7) + * @returns {Object} Map of memberId -> dailyResult[], ordered newest-first + */ +const getBulkMemberDailyResults = async (memberIds, daysBack = 7) => { + if (!memberIds || memberIds.length === 0) return {}; + + const since = normaliseToMidnight(); + since.setDate(since.getDate() - (daysBack - 1)); + + const results = await prisma.dailyResult.findMany({ + where: { + memberId: { in: memberIds }, + date: { gte: since }, + }, + orderBy: { date: "desc" }, + }); + + return results.reduce((acc, result) => { + if (!acc[result.memberId]) acc[result.memberId] = []; + acc[result.memberId].push(result); + return acc; + }, {}); +}; + +/** + * Get today's daily result for multiple members in a single bulk query. + * Results are returned as a map keyed by memberId for O(1) lookup. + * @param {string[]} memberIds - Array of challenge member IDs + * @returns {Object} Map of memberId -> dailyResult (or undefined if none) + */ +const getBulkTodayResults = async (memberIds) => { + if (!memberIds || memberIds.length === 0) return {}; + + const today = normaliseToMidnight(); + + const results = await prisma.dailyResult.findMany({ + where: { + memberId: { in: memberIds }, + date: today, + }, + }); + + return results.reduce((acc, result) => { + acc[result.memberId] = result; + return acc; + }, {}); +}; + /** * Get today's status for a member * @param {string} memberId - Challenge member ID @@ -343,5 +415,7 @@ module.exports = { evaluateChallenge, evaluateMember, getMemberDailyResults, + getBulkMemberDailyResults, + getBulkTodayResults, getTodayStatus, }; From 9e8fe9bce03dbff4bcbef74c01ea824788a9d519 Mon Sep 17 00:00:00 2001 From: Aryan Parikh Date: Mon, 23 Feb 2026 22:51:32 +0530 Subject: [PATCH 4/9] refactor: address PR review comments - fix remaining N+1 issues - Fix N+1 in getChallengeLeaderboard: replace per-member prisma loop with getBulkAllMemberResults() which fetches all dailyResult rows for all members in one query (selecting only memberId + completed) and aggregates totalDays/completedDays in-memory - Use normaliseToMidnight() in getTodayStatus service function instead of inline setHours pattern, consistent with new helper convention - Export getBulkAllMemberResults from evaluation.service.js --- src/controllers/dashboard.controller.js | 48 ++++++++++++------------- src/services/evaluation.service.js | 28 +++++++++++++-- 2 files changed, 50 insertions(+), 26 deletions(-) diff --git a/src/controllers/dashboard.controller.js b/src/controllers/dashboard.controller.js index 684d760..5eb8615 100644 --- a/src/controllers/dashboard.controller.js +++ b/src/controllers/dashboard.controller.js @@ -182,30 +182,30 @@ const getChallengeLeaderboard = asyncHandler(async (req, res) => { ], }); - // Get total completed days for each member - const leaderboard = await Promise.all( - members.map(async (member) => { - const results = await prisma.dailyResult.findMany({ - where: { memberId: member.id }, - }); - - const totalDays = results.length; - const completedDays = results.filter((r) => r.completed).length; - const completionRate = - totalDays > 0 ? (completedDays / totalDays) * 100 : 0; - - return { - username: member.user.username, - leetcodeUsername: member.user.leetcodeUsername, - currentStreak: member.currentStreak, - longestStreak: member.longestStreak, - totalPenalties: member.totalPenalties, - completedDays, - totalDays, - completionRate: completionRate.toFixed(2), - }; - }) - ); + if (members.length === 0) { + return res.status(200).json({ success: true, data: [] }); + } + + const memberIds = members.map((m) => m.id); + + // Delegate bulk fetching to the service layer — one query for all members + const statsByMember = await evaluationService.getBulkAllMemberResults(memberIds); + + const leaderboard = members.map((member) => { + const { totalDays = 0, completedDays = 0 } = statsByMember[member.id] || {}; + const completionRate = totalDays > 0 ? (completedDays / totalDays) * 100 : 0; + + return { + username: member.user.username, + leetcodeUsername: member.user.leetcodeUsername, + currentStreak: member.currentStreak, + longestStreak: member.longestStreak, + totalPenalties: member.totalPenalties, + completedDays, + totalDays, + completionRate: completionRate.toFixed(2), + }; + }); res.status(200).json({ success: true, diff --git a/src/services/evaluation.service.js b/src/services/evaluation.service.js index 9bf93ed..ec7eae6 100644 --- a/src/services/evaluation.service.js +++ b/src/services/evaluation.service.js @@ -364,6 +364,30 @@ const getBulkMemberDailyResults = async (memberIds, daysBack = 7) => { }, {}); }; +/** + * Get all daily results for multiple members in a single bulk query. + * Returns aggregated stats (totalDays, completedDays) grouped by memberId, + * used by the leaderboard which needs full-history counts rather than a + * calendar window. + * @param {string[]} memberIds - Array of challenge member IDs + * @returns {Object} Map of memberId -> { totalDays, completedDays } + */ +const getBulkAllMemberResults = async (memberIds) => { + if (!memberIds || memberIds.length === 0) return {}; + + const results = await prisma.dailyResult.findMany({ + where: { memberId: { in: memberIds } }, + select: { memberId: true, completed: true }, + }); + + return results.reduce((acc, result) => { + if (!acc[result.memberId]) acc[result.memberId] = { totalDays: 0, completedDays: 0 }; + acc[result.memberId].totalDays += 1; + if (result.completed) acc[result.memberId].completedDays += 1; + return acc; + }, {}); +}; + /** * Get today's daily result for multiple members in a single bulk query. * Results are returned as a map keyed by memberId for O(1) lookup. @@ -394,8 +418,7 @@ const getBulkTodayResults = async (memberIds) => { * @returns {Object|null} Today's daily result or null */ const getTodayStatus = async (memberId) => { - const today = new Date(); - today.setHours(0, 0, 0, 0); + const today = normaliseToMidnight(); return await prisma.dailyResult.findUnique({ where: { @@ -416,6 +439,7 @@ module.exports = { evaluateMember, getMemberDailyResults, getBulkMemberDailyResults, + getBulkAllMemberResults, getBulkTodayResults, getTodayStatus, }; From 2cce10b40862dce7b139196895860f39ef5f5094 Mon Sep 17 00:00:00 2001 From: PrIyAnSh095 Date: Tue, 24 Feb 2026 16:12:53 +0530 Subject: [PATCH 5/9] fix/profile-validation-null-safety --- src/controllers/auth.controller.js | 34 ++++++++++++++++++++++++++++++ src/routes/auth.routes.js | 7 +++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/controllers/auth.controller.js b/src/controllers/auth.controller.js index b337dea..fa38edb 100644 --- a/src/controllers/auth.controller.js +++ b/src/controllers/auth.controller.js @@ -36,6 +36,7 @@ const validateLogin = [ ]; /** +<<<<<<< HEAD * Validation middleware for forgot password */ const validateForgotPassword = [ @@ -53,6 +54,25 @@ const validateResetPassword = [ body("newPassword") .isLength({ min: 6 }) .withMessage("New password must be at least 6 characters"), +======= + * Validation middleware for profile update + */ +const validateUpdateProfile = [ + body("leetcodeUsername") + .optional({ nullable: true }) + .isString() + .isLength({ min: 1, max: 50 }) + .withMessage("LeetCode username must be 1-50 characters"), + body("newPassword") + .optional() + .isString() + .isLength({ min: 6 }) + .withMessage("New password must be at least 6 characters"), + body("currentPassword") + .if(body("newPassword").exists({ checkFalsy: true })) + .notEmpty() + .withMessage("Current password is required when setting a new password"), +>>>>>>> c52549d (fix/profile-validation-null-safety) ]; /** @@ -130,6 +150,16 @@ const getProfile = asyncHandler(async (req, res) => { * PUT /api/auth/profile */ const updateProfile = asyncHandler(async (req, res) => { + // Check for validation errors + const errors = validationResult(req); + if (!errors.isEmpty()) { + return res.status(400).json({ + success: false, + message: "Validation failed", + errors: errors.array(), + }); + } + const { leetcodeUsername, currentPassword, newPassword } = req.body; const user = await authService.updateProfile(req.user.id, { @@ -198,8 +228,12 @@ module.exports = { updateProfile, validateRegister, validateLogin, +<<<<<<< HEAD forgotPassword, resetPassword, validateForgotPassword, validateResetPassword, +======= + validateUpdateProfile, +>>>>>>> c52549d (fix/profile-validation-null-safety) }; diff --git a/src/routes/auth.routes.js b/src/routes/auth.routes.js index ca736c1..484906c 100644 --- a/src/routes/auth.routes.js +++ b/src/routes/auth.routes.js @@ -55,6 +55,11 @@ router.get("/profile", authenticate, authController.getProfile); * @desc Update user profile * @access Private */ -router.put("/profile", authenticate, authController.updateProfile); +router.put( + "/profile", + authenticate, + authController.validateUpdateProfile, + authController.updateProfile +); module.exports = router; From d0ddd71dbe31954efea3bcb0cba0d72cdad7beff Mon Sep 17 00:00:00 2001 From: vasu kamani Date: Thu, 26 Feb 2026 20:00:08 +0530 Subject: [PATCH 6/9] Add database seeding script and Postman collection for API testing - Created `prisma/seed.js` to seed the database with sample users, problems, challenges, memberships, daily results, and penalty ledger entries. - Updated `package.json` to include seed scripts for easy execution. - Added `Postman_Collection.json` for API endpoints testing, including health checks, authentication, challenge management, dashboard analytics, and LeetCode integration. - Introduced `postman_environment.json` for environment variable management in Postman. - Documented the seeding and testing process in `SEEDING_AND_TESTING.md` for user guidance. - Created `postman/postman_README.md` to provide an overview of Postman files and quick start instructions. --- Postman_Collection.json | 667 ------------------------------- SEEDING_AND_TESTING.md | 168 ++++++++ package.json | 7 +- postman/Postman_Collection.json | 618 ++++++++++++++++++++++++++++ postman/postman_README.md | 87 ++++ postman/postman_environment.json | 44 ++ prisma/seed.js | 411 +++++++++++++++++++ 7 files changed, 1334 insertions(+), 668 deletions(-) delete mode 100644 Postman_Collection.json create mode 100644 SEEDING_AND_TESTING.md create mode 100644 postman/Postman_Collection.json create mode 100644 postman/postman_README.md create mode 100644 postman/postman_environment.json create mode 100644 prisma/seed.js diff --git a/Postman_Collection.json b/Postman_Collection.json deleted file mode 100644 index a9bf2f9..0000000 --- a/Postman_Collection.json +++ /dev/null @@ -1,667 +0,0 @@ -{ - "info": { - "name": "LeetCode Daily Challenge Tracker API", - "description": "Complete API collection for testing the LeetCode Daily Challenge Tracker backend\n\n⚠️ TESTING FLOW:\n1. Start with Health Check endpoints (no auth required)\n2. Register a new user or Login (token auto-saves)\n3. All other endpoints require the JWT token from step 2\n4. Create and join challenges\n5. View dashboard and progress\n\n🔑 The JWT token is automatically saved to {{jwt_token}} variable after login/register", - "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", - "version": "1.0.0" - }, - "auth": { - "type": "bearer", - "bearer": [ - { - "key": "token", - "value": "{{jwt_token}}", - "type": "string" - } - ] - }, - "variable": [ - { - "key": "base_url", - "value": "http://localhost:3000", - "type": "string" - }, - { - "key": "jwt_token", - "value": "", - "type": "string" - }, - { - "key": "user_id", - "value": "", - "type": "string" - }, - { - "key": "challenge_id", - "value": "", - "type": "string" - } - ], - "item": [ - { - "name": "🏥 Health Check", - "item": [ - { - "name": "Server Health", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/health", - "host": ["{{base_url}}"], - "path": ["health"] - } - }, - "response": [] - }, - { - "name": "API Root", - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/", - "host": ["{{base_url}}"], - "path": [""] - } - }, - "response": [] - } - ] - }, - { - "name": "🔐 Authentication", - "item": [ - { - "name": "Register User", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "if (pm.response.code === 201) {", - " const response = pm.response.json();", - " pm.collectionVariables.set('jwt_token', response.data.token);", - " pm.collectionVariables.set('user_id', response.data.user.id);", - " console.log('✅ JWT Token saved:', response.data.token);", - " console.log('✅ User ID saved:', response.data.user.id);", - "}" - ] - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n \"email\": \"john.doe@example.com\",\n \"username\": \"john_doe\",\n \"password\": \"password123\",\n \"leetcodeUsername\": \"john_leetcode\"\n}" - }, - "url": { - "raw": "{{base_url}}/api/auth/register", - "host": ["{{base_url}}"], - "path": ["api", "auth", "register"] - } - }, - "response": [] - }, - { - "name": "Login User", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "if (pm.response.code === 200) {", - " const response = pm.response.json();", - " pm.collectionVariables.set('jwt_token', response.data.token);", - " pm.collectionVariables.set('user_id', response.data.user.id);", - " console.log('✅ JWT Token saved:', response.data.token);", - " console.log('✅ User ID saved:', response.data.user.id);", - "}" - ] - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n \"emailOrUsername\": \"john_doe\",\n \"password\": \"password123\"\n}" - }, - "url": { - "raw": "{{base_url}}/api/auth/login", - "host": ["{{base_url}}"], - "path": ["api", "auth", "login"] - } - }, - "response": [] - }, - { - "name": "Get Profile", - "event": [ - { - "listen": "prerequest", - "script": { - "exec": [ - "// Check if token exists", - "const token = pm.collectionVariables.get('jwt_token');", - "if (!token || token === '') {", - " console.error('⚠️ No JWT token found! Please run Login or Register first.');", - "} else {", - " console.log('✅ Using JWT Token:', token.substring(0, 50) + '...');", - "}" - ] - } - } - ], - "request": { - "auth": { - "type": "bearer", - "bearer": [ - { - "key": "token", - "value": "{{jwt_token}}", - "type": "string" - } - ] - }, - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/api/auth/profile", - "host": ["{{base_url}}"], - "path": ["api", "auth", "profile"] - } - }, - "response": [] - }, - { - "name": "Update Profile", - "request": { - "auth": { - "type": "bearer", - "bearer": [ - { - "key": "token", - "value": "{{jwt_token}}", - "type": "string" - } - ] - }, - "method": "PUT", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n \"leetcodeUsername\": \"new_leetcode_username\"\n}" - }, - "url": { - "raw": "{{base_url}}/api/auth/profile", - "host": ["{{base_url}}"], - "path": ["api", "auth", "profile"] - } - }, - "response": [] - } - ] - }, - { - "name": "🎯 Challenges", - "item": [ - { - "name": "Create Challenge", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "if (pm.response.code === 201) {", - " const response = pm.response.json();", - " pm.collectionVariables.set('challenge_id', response.data.id);", - " console.log('✅ Challenge ID saved:', response.data.id);", - "}" - ] - } - } - ], - "request": { - "auth": { - "type": "bearer", - "bearer": [ - { - "key": "token", - "value": "{{jwt_token}}", - "type": "string" - } - ] - }, - "method": "POST", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n \"name\": \"January 2026 Daily Challenge\",\n \"description\": \"Solve at least 1 Medium or Hard problem daily\",\n \"minSubmissionsPerDay\": 1,\n \"difficultyFilter\": [\"Medium\", \"Hard\"],\n \"uniqueProblemConstraint\": true,\n \"penaltyAmount\": 100,\n \"startDate\": \"2026-01-07T00:00:00.000Z\",\n \"endDate\": \"2026-01-31T23:59:59.999Z\"\n}" - }, - "url": { - "raw": "{{base_url}}/api/challenges", - "host": ["{{base_url}}"], - "path": ["api", "challenges"] - } - }, - "response": [] - }, - { - "name": "Get All User Challenges", - "request": { - "auth": { - "type": "bearer", - "bearer": [ - { - "key": "token", - "value": "{{jwt_token}}", - "type": "string" - } - ] - }, - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/api/challenges", - "host": ["{{base_url}}"], - "path": ["api", "challenges"] - } - }, - "response": [] - }, - { - "name": "Get Active Challenges", - "request": { - "auth": { - "type": "bearer", - "bearer": [ - { - "key": "token", - "value": "{{jwt_token}}", - "type": "string" - } - ] - }, - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/api/challenges?status=ACTIVE", - "host": ["{{base_url}}"], - "path": ["api", "challenges"], - "query": [ - { - "key": "status", - "value": "ACTIVE" - } - ] - } - }, - "response": [] - }, - { - "name": "Get Owned Challenges", - "request": { - "auth": { - "type": "bearer", - "bearer": [ - { - "key": "token", - "value": "{{jwt_token}}", - "type": "string" - } - ] - }, - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/api/challenges?owned=true", - "host": ["{{base_url}}"], - "path": ["api", "challenges"], - "query": [ - { - "key": "owned", - "value": "true" - } - ] - } - }, - "response": [] - }, - { - "name": "Get Challenge By ID", - "request": { - "auth": { - "type": "bearer", - "bearer": [ - { - "key": "token", - "value": "{{jwt_token}}", - "type": "string" - } - ] - }, - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/api/challenges/{{challenge_id}}", - "host": ["{{base_url}}"], - "path": ["api", "challenges", "{{challenge_id}}"] - } - }, - "response": [] - }, - { - "name": "Join Challenge", - "request": { - "auth": { - "type": "bearer", - "bearer": [ - { - "key": "token", - "value": "{{jwt_token}}", - "type": "string" - } - ] - }, - "method": "POST", - "header": [], - "url": { - "raw": "{{base_url}}/api/challenges/{{challenge_id}}/join", - "host": ["{{base_url}}"], - "path": ["api", "challenges", "{{challenge_id}}", "join"] - } - }, - "response": [] - }, - { - "name": "Update Challenge Status - Start", - "request": { - "auth": { - "type": "bearer", - "bearer": [ - { - "key": "token", - "value": "{{jwt_token}}", - "type": "string" - } - ] - }, - "method": "PATCH", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n \"status\": \"ACTIVE\"\n}" - }, - "url": { - "raw": "{{base_url}}/api/challenges/{{challenge_id}}/status", - "host": ["{{base_url}}"], - "path": ["api", "challenges", "{{challenge_id}}", "status"] - } - }, - "response": [] - }, - { - "name": "Update Challenge Status - Complete", - "request": { - "auth": { - "type": "bearer", - "bearer": [ - { - "key": "token", - "value": "{{jwt_token}}", - "type": "string" - } - ] - }, - "method": "PATCH", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{\n \"status\": \"COMPLETED\"\n}" - }, - "url": { - "raw": "{{base_url}}/api/challenges/{{challenge_id}}/status", - "host": ["{{base_url}}"], - "path": ["api", "challenges", "{{challenge_id}}", "status"] - } - }, - "response": [] - } - ] - }, - { - "name": "📊 Dashboard", - "item": [ - { - "name": "Get Dashboard Overview", - "request": { - "auth": { - "type": "bearer", - "bearer": [ - { - "key": "token", - "value": "{{jwt_token}}", - "type": "string" - } - ] - }, - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/api/dashboard", - "host": ["{{base_url}}"], - "path": ["api", "dashboard"] - } - }, - "response": [] - }, - { - "name": "Get Today's Status", - "request": { - "auth": { - "type": "bearer", - "bearer": [ - { - "key": "token", - "value": "{{jwt_token}}", - "type": "string" - } - ] - }, - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/api/dashboard/today", - "host": ["{{base_url}}"], - "path": ["api", "dashboard", "today"] - } - }, - "response": [] - }, - { - "name": "Get Challenge Progress", - "request": { - "auth": { - "type": "bearer", - "bearer": [ - { - "key": "token", - "value": "{{jwt_token}}", - "type": "string" - } - ] - }, - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/api/dashboard/challenge/{{challenge_id}}", - "host": ["{{base_url}}"], - "path": ["api", "dashboard", "challenge", "{{challenge_id}}"] - } - }, - "response": [] - }, - { - "name": "Get Challenge Leaderboard", - "request": { - "auth": { - "type": "bearer", - "bearer": [ - { - "key": "token", - "value": "{{jwt_token}}", - "type": "string" - } - ] - }, - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/api/dashboard/challenge/{{challenge_id}}/leaderboard", - "host": ["{{base_url}}"], - "path": [ - "api", - "dashboard", - "challenge", - "{{challenge_id}}", - "leaderboard" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "💻 LeetCode Integration", - "item": [ - { - "name": "Get LeetCode Profile", - "request": { - "auth": { - "type": "bearer", - "bearer": [ - { - "key": "token", - "value": "{{jwt_token}}", - "type": "string" - } - ] - }, - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/api/leetcode/profile/krishnapaljadeja", - "host": ["{{base_url}}"], - "path": ["api", "leetcode", "profile", "krishnapaljadeja"] - } - }, - "response": [] - }, - { - "name": "Test LeetCode Connection", - "request": { - "auth": { - "type": "bearer", - "bearer": [ - { - "key": "token", - "value": "{{jwt_token}}", - "type": "string" - } - ] - }, - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/api/leetcode/test/krishnapaljadeja", - "host": ["{{base_url}}"], - "path": ["api", "leetcode", "test", "krishnapaljadeja"] - } - }, - "response": [] - }, - { - "name": "Get Problem Metadata - Two Sum", - "request": { - "auth": { - "type": "bearer", - "bearer": [ - { - "key": "token", - "value": "{{jwt_token}}", - "type": "string" - } - ] - }, - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/api/leetcode/problem/two-sum", - "host": ["{{base_url}}"], - "path": ["api", "leetcode", "problem", "two-sum"] - } - }, - "response": [] - }, - { - "name": "Get Problem Metadata - Add Two Numbers", - "request": { - "auth": { - "type": "bearer", - "bearer": [ - { - "key": "token", - "value": "{{jwt_token}}", - "type": "string" - } - ] - }, - "method": "GET", - "header": [], - "url": { - "raw": "{{base_url}}/api/leetcode/problem/add-two-numbers", - "host": ["{{base_url}}"], - "path": ["api", "leetcode", "problem", "add-two-numbers"] - } - }, - "response": [] - } - ] - } - ] -} diff --git a/SEEDING_AND_TESTING.md b/SEEDING_AND_TESTING.md new file mode 100644 index 0000000..2275548 --- /dev/null +++ b/SEEDING_AND_TESTING.md @@ -0,0 +1,168 @@ +# Database Seeding & API Testing Guide + +This document explains how to use the database seed script and Postman collection to set up sample data and test the CodeDuel backend APIs. + +## 📦 Database Seeding + +### Overview + +The seed script (`prisma/seed.js`) populates the database with realistic sample data, including: +- **5 Sample Users** with different roles and activity levels +- **10 LeetCode Problems** with realistic metadata (difficulties, acceptance rates, tags) +- **5 Challenges** with various configurations: + - Easy challenges for beginners + - Medium/Hard challenges for advanced users + - Public and private challenges + - Different penalty structures +- **Challenge Memberships** - Users joined to challenges with realistic stats +- **Daily Results** - 7 days of activity per member with completion data +- **Penalty Ledger** - Sample penalty records for inactive members + +### Running the Seed + +#### Option 1: Using npm script (recommended) +```bash +npm run seed +``` + +#### Option 2: Using Prisma CLI +```bash +npx prisma db seed +``` + +#### Option 3: Direct execution +```bash +node prisma/seed.js +``` + +### Sample Users (for testing) + +After running the seed, you can login with these credentials: + +| Username | Email | Password | LeetCode Username | +|----------|-------|----------|------------------| +| johndoe | john.doe@example.com | password123 | john_doe | +| janesmith | jane.smith@example.com | password123 | jane_smith | +| bobwilson | bob.wilson@example.com | password123 | bob_wilson | +| alicejohnson | alice.johnson@example.com | password123 | alice_johnson | +| charliebrown | charlie.brown@example.com | password123 | charlie_brown | + +## 🔧 Postman Collection + +### Setup + +1. **Import the Collection** + - Open Postman + - Click "Import" → Select `Postman_Collection.json` + - The collection will include all API endpoints and sample requests + +2. **Import the Environment (Optional)** + - Click "Import" → Select `postman_environment.json` + - This provides pre-configured variables for local testing + +3. **Configure Variables** + - The collection uses these variables: + - `{{base_url}}` - Server URL (default: `http://localhost:3000`) + - `{{jwt_token}}` - JWT token (auto-populated after login) + - `{{challenge_id}}` - Challenge ID (auto-populated after creating challenge) + - `{{member_id}}` - Member ID (auto-populated after joining challenge) + - `{{user_id}}` - User ID (auto-populated after login) + +### Testing Workflow + +#### Step 1: Health Check +``` +GET /health +``` +No authentication required. Verify the server is running. + +#### Step 2: Authentication +Either **Register** a new user or **Login** with seed credentials: + +**Login with existing user (recommended):** +``` +POST /api/auth/login +{ + "emailOrUsername": "johndoe", + "password": "password123" +} +``` + +The JWT token will be automatically saved to `{{jwt_token}}` variable. + +#### Step 3: Create a Challenge (Optional) +``` +POST /api/challenges +``` +Create a new challenge with your preferred settings. + +#### Step 4: Get All Challenges +``` +GET /api/challenges +``` +List all challenges you own or are a member of. + +#### Step 5: Join a Challenge +``` +POST /api/challenges/{{challenge_id}}/join +``` +Join an existing public challenge. + +#### Step 6: View Dashboard +``` +GET /api/dashboard +``` +View your overall dashboard with stats and active challenges. + +#### Step 7: Dashboard Details +``` +GET /api/dashboard/challenge/{{challenge_id}} +GET /api/dashboard/challenge/{{challenge_id}}/leaderboard +GET /api/dashboard/activity-heatmap +GET /api/dashboard/stats +GET /api/dashboard/submission-chart +``` +Explore various dashboard views and analytics. + +#### Step 8: LeetCode Integration +``` +GET /api/leetcode/profile/{username} +GET /api/leetcode/problem/{titleSlug} +``` +Test LeetCode integration endpoints. + +### Collection Organization + +The collection is organized into 5 folders: + +1. **🏥 Health Check** + - Server Health + - API Root + +2. **🔐 Authentication** + - Register New User + - Login with Seed User + - Get Current Profile + - Update Profile (LeetCode Username) + - Update Profile (Password) + +3. **🎯 Challenges** + - Create New Challenge + - Get All User Challenges + - Get Challenge by ID + - Join Challenge + - Update Challenge Status (ACTIVE/COMPLETED) + +4. **📊 Dashboard** + - Get Dashboard Overview + - Get Today's Status + - Get Challenge Progress + - Get Challenge Leaderboard + - Get Activity Heatmap + - Get User Stats + - Get Submission Chart + +5. **💻 LeetCode Integration** + - Get LeetCode User Profile + - Test LeetCode Connection + - Get Problem Metadata (Multiple problems) diff --git a/package.json b/package.json index d152cc3..1040497 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,9 @@ "dev": "nodemon src/server.js", "prisma:generate": "prisma generate", "prisma:migrate": "prisma migrate dev", - "prisma:studio": "prisma studio" + "prisma:studio": "prisma studio", + "seed": "node prisma/seed.js", + "db:seed": "prisma db seed" }, "keywords": [ "leetcode", @@ -40,5 +42,8 @@ }, "devDependencies": { "nodemon": "^3.0.2" + }, + "prisma": { + "seed": "node prisma/seed.js" } } diff --git a/postman/Postman_Collection.json b/postman/Postman_Collection.json new file mode 100644 index 0000000..7d30f1e --- /dev/null +++ b/postman/Postman_Collection.json @@ -0,0 +1,618 @@ +{ + "info": { + "name": "CodeDuel LeetCode Challenge Tracker API", + "description": "Complete API collection for the CodeDuel - LeetCode Daily Challenge Tracker backend\n\n**QUICK START GUIDE:**\n1. Start by running the seed script: `npm run seed` or `npx prisma db seed`\n2. Test Health endpoint (no auth required)\n3. Register or Login to get JWT token\n4. Use token for other endpoints\n5. Create challenges, join challenges, view dashboards\n\n**SAMPLE TEST CREDENTIALS** (from seed):\n- johndoe / password123\n- janesmith / password123\n- bobwilson / password123\n- alicejohnson / password123\n- charliebrown / password123\n\n**VARIABLES:**\n- {{base_url}}: Server base URL (default: http://localhost:3000)\n- {{jwt_token}}: JWT token (auto-saved after login)\n- {{user_id}}: Current user ID\n- {{challenge_id}}: Challenge ID for testing\n- {{member_id}}: Challenge member ID", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "version": "2.0.0" + }, + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{jwt_token}}", + "type": "string" + } + ] + }, + "variable": [ + { + "key": "base_url", + "value": "http://localhost:3000", + "type": "string" + }, + { + "key": "jwt_token", + "value": "", + "type": "string" + }, + { + "key": "user_id", + "value": "", + "type": "string" + }, + { + "key": "challenge_id", + "value": "", + "type": "string" + }, + { + "key": "member_id", + "value": "", + "type": "string" + } + ], + "item": [ + { + "name": "🏥 Health Check", + "item": [ + { + "name": "Server Health", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test('Status code is 200', function () {", + " pm.response.to.have.status(200);", + "});", + "pm.test('Response has success message', function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.success).to.eql(true);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/health", + "host": ["{{base_url}}"], + "path": ["health"] + } + }, + "response": [] + }, + { + "name": "API Root", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/", + "host": ["{{base_url}}"], + "path": [""] + } + }, + "response": [] + } + ] + }, + { + "name": "🔐 Authentication", + "item": [ + { + "name": "Register New User", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test('Status code is 201', function () {", + " pm.response.to.have.status(201);", + "});", + "pm.test('Response has JWT token', function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.data).to.have.property('token');", + " pm.environment.set('jwt_token', jsonData.data.token);", + " pm.environment.set('user_id', jsonData.data.user.id);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"email\": \"testuser@example.com\",\n \"username\": \"testuser\",\n \"password\": \"password123\",\n \"leetcodeUsername\": \"test_user\"\n}" + }, + "url": { + "raw": "{{base_url}}/api/auth/register", + "host": ["{{base_url}}"], + "path": ["api", "auth", "register"] + } + }, + "response": [] + }, + { + "name": "Login with Seed User", + "description": "Login using credentials from seed data: johndoe / password123", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test('Status code is 200', function () {", + " pm.response.to.have.status(200);", + "});", + "pm.test('Response has JWT token', function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.data).to.have.property('token');", + " pm.environment.set('jwt_token', jsonData.data.token);", + " pm.environment.set('user_id', jsonData.data.user.id);", + " console.log('✅ JWT Token saved');", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"emailOrUsername\": \"johndoe\",\n \"password\": \"password123\"\n}" + }, + "url": { + "raw": "{{base_url}}/api/auth/login", + "host": ["{{base_url}}"], + "path": ["api", "auth", "login"] + } + }, + "response": [] + }, + { + "name": "Get Current Profile", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/api/auth/profile", + "host": ["{{base_url}}"], + "path": ["api", "auth", "profile"] + } + }, + "response": [] + }, + { + "name": "Update Profile (LeetCode Username)", + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"leetcodeUsername\": \"updated_john_doe_username\"\n}" + }, + "url": { + "raw": "{{base_url}}/api/auth/profile", + "host": ["{{base_url}}"], + "path": ["api", "auth", "profile"] + } + }, + "response": [] + }, + { + "name": "Update Profile (Password)", + "request": { + "method": "PUT", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"currentPassword\": \"password123\",\n \"newPassword\": \"newpassword123\"\n}" + }, + "url": { + "raw": "{{base_url}}/api/auth/profile", + "host": ["{{base_url}}"], + "path": ["api", "auth", "profile"] + } + }, + "response": [] + } + ] + }, + { + "name": "🎯 Challenges", + "item": [ + { + "name": "Create New Challenge", + "description": "Create a new challenge. Data matches seed data structure.", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test('Status code is 201', function () {", + " pm.response.to.have.status(201);", + "});", + "pm.test('Response has challenge data', function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.data).to.have.property('id');", + " pm.environment.set('challenge_id', jsonData.data.id);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"Advanced Algorithms Challenge\",\n \"description\": \"Master advanced algorithmic concepts through daily problem solving\",\n \"minSubmissionsPerDay\": 2,\n \"difficultyFilter\": [\"Medium\", \"Hard\"],\n \"uniqueProblemConstraint\": true,\n \"penaltyAmount\": 10,\n \"visibility\": \"PUBLIC\",\n \"startDate\": \"2026-02-26T00:00:00Z\",\n \"endDate\": \"2026-03-31T23:59:59Z\"\n}" + }, + "url": { + "raw": "{{base_url}}/api/challenges", + "host": ["{{base_url}}"], + "path": ["api", "challenges"] + } + }, + "response": [] + }, + { + "name": "Get All User Challenges", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test('Status code is 200', function () {", + " pm.response.to.have.status(200);", + "});", + "pm.test('Response is an array', function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.data).to.be.an('array');", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/api/challenges", + "host": ["{{base_url}}"], + "path": ["api", "challenges"] + } + }, + "response": [] + }, + { + "name": "Get Challenge by ID", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test('Status code is 200', function () {", + " pm.response.to.have.status(200);", + "});", + "pm.test('Response has challenge details', function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.data).to.have.property('id');", + " pm.expect(jsonData.data).to.have.property('name');", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/api/challenges/{{challenge_id}}", + "host": ["{{base_url}}"], + "path": ["api", "challenges", "{{challenge_id}}"] + } + }, + "response": [] + }, + { + "name": "Join Challenge", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test('Status code is 200', function () {", + " pm.response.to.have.status(200);", + "});", + "pm.test('Response has membership data', function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.data).to.have.property('id');", + " pm.environment.set('member_id', jsonData.data.id);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "url": { + "raw": "{{base_url}}/api/challenges/{{challenge_id}}/join", + "host": ["{{base_url}}"], + "path": ["api", "challenges", "{{challenge_id}}", "join"] + } + }, + "response": [] + }, + { + "name": "Update Challenge Status to ACTIVE", + "request": { + "method": "PATCH", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"status\": \"ACTIVE\"\n}" + }, + "url": { + "raw": "{{base_url}}/api/challenges/{{challenge_id}}/status", + "host": ["{{base_url}}"], + "path": ["api", "challenges", "{{challenge_id}}", "status"] + } + }, + "response": [] + }, + { + "name": "Update Challenge Status to COMPLETED", + "request": { + "method": "PATCH", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"status\": \"COMPLETED\"\n}" + }, + "url": { + "raw": "{{base_url}}/api/challenges/{{challenge_id}}/status", + "host": ["{{base_url}}"], + "path": ["api", "challenges", "{{challenge_id}}", "status"] + } + }, + "response": [] + } + ] + }, + { + "name": "📊 Dashboard", + "item": [ + { + "name": "Get Dashboard Overview", + "description": "Get comprehensive dashboard data with all active challenges and stats", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test('Status code is 200', function () {", + " pm.response.to.have.status(200);", + "});", + "pm.test('Response has dashboard data', function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.data).to.have.property('activeChallenges');", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/api/dashboard", + "host": ["{{base_url}}"], + "path": ["api", "dashboard"] + } + }, + "response": [] + }, + { + "name": "Get Today's Status", + "description": "Get today's completion status across all active challenges", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/api/dashboard/today", + "host": ["{{base_url}}"], + "path": ["api", "dashboard", "today"] + } + }, + "response": [] + }, + { + "name": "Get Challenge Progress", + "description": "Get detailed progress for a specific challenge including daily results and members", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/api/dashboard/challenge/{{challenge_id}}", + "host": ["{{base_url}}"], + "path": ["api", "dashboard", "challenge", "{{challenge_id}}"] + } + }, + "response": [] + }, + { + "name": "Get Challenge Leaderboard", + "description": "Get leaderboard for a specific challenge with member rankings", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/api/dashboard/challenge/{{challenge_id}}/leaderboard", + "host": ["{{base_url}}"], + "path": ["api", "dashboard", "challenge", "{{challenge_id}}", "leaderboard"] + } + }, + "response": [] + }, + { + "name": "Get Activity Heatmap", + "description": "Get user's activity heatmap data for the last 365 days", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/api/dashboard/activity-heatmap", + "host": ["{{base_url}}"], + "path": ["api", "dashboard", "activity-heatmap"] + } + }, + "response": [] + }, + { + "name": "Get User Stats", + "description": "Get user's comprehensive stats including streaks and totals", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/api/dashboard/stats", + "host": ["{{base_url}}"], + "path": ["api", "dashboard", "stats"] + } + }, + "response": [] + }, + { + "name": "Get Submission Chart", + "description": "Get user's submission chart data for the last 30 days", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/api/dashboard/submission-chart", + "host": ["{{base_url}}"], + "path": ["api", "dashboard", "submission-chart"] + } + }, + "response": [] + } + ] + }, + { + "name": "💻 LeetCode Integration", + "item": [ + { + "name": "Get LeetCode User Profile", + "description": "Fetch a user's profile and solved problem statistics from LeetCode (using sample username from seed)", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/api/leetcode/profile/john_doe", + "host": ["{{base_url}}"], + "path": ["api", "leetcode", "profile", "john_doe"] + } + }, + "response": [] + }, + { + "name": "Test LeetCode Connection", + "description": "Test connectivity with LeetCode API using a sample username", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/api/leetcode/test/john_doe", + "host": ["{{base_url}}"], + "path": ["api", "leetcode", "test", "john_doe"] + } + }, + "response": [] + }, + { + "name": "Get Problem Metadata - Two Sum", + "description": "Get metadata for the 'Two Sum' problem (ID: 1, Easy difficulty)", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/api/leetcode/problem/two-sum", + "host": ["{{base_url}}"], + "path": ["api", "leetcode", "problem", "two-sum"] + } + }, + "response": [] + }, + { + "name": "Get Problem Metadata - Add Two Numbers", + "description": "Get metadata for the 'Add Two Numbers' problem (ID: 2, Medium difficulty)", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/api/leetcode/problem/add-two-numbers", + "host": ["{{base_url}}"], + "path": ["api", "leetcode", "problem", "add-two-numbers"] + } + }, + "response": [] + }, + { + "name": "Get Problem Metadata - Longest Substring", + "description": "Get metadata for 'Longest Substring Without Repeating Characters' (ID: 3, Medium difficulty)", + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{base_url}}/api/leetcode/problem/longest-substring-without-repeating-characters", + "host": ["{{base_url}}"], + "path": ["api", "leetcode", "problem", "longest-substring-without-repeating-characters"] + } + }, + "response": [] + } + ] + } + ] +} diff --git a/postman/postman_README.md b/postman/postman_README.md new file mode 100644 index 0000000..a5c9b96 --- /dev/null +++ b/postman/postman_README.md @@ -0,0 +1,87 @@ +# Postman Collection & Environment + +This directory contains Postman files for testing the CodeDuel backend API. + +## Files + +### 📋 `Postman_Collection.json` +The main API collection containing all endpoints grouped by feature: +- Health checks +- Authentication (login/register) +- Challenge management +- Dashboard analytics +- LeetCode integration + +**Import this file into Postman to get started.** + +### 🔧 `postman_environment.json` +Environment configuration file with pre-set variables: +- Base URL: `http://localhost:3000` +- JWT token storage +- Challenge and user ID variables +- API timeout and content-type settings + +**Optional but recommended for development.** + +## Quick Start + +1. **Open Postman** (download from https://www.postman.com/downloads/) + +2. **Import the Collection** + - Click "Import" button + - Select `Postman_Collection.json` + - The collection appears in the left sidebar + +3. **Import the Environment** (optional) + - Click "Import" button + - Select `postman_environment.json` + - Select it from the environment dropdown (top-right) + +4. **Seed the Database** + - Run `npm run seed` from backend root + - This creates sample users, challenges, and data + +5. **Test the API** + - Start with "🏥 Health Check" → "Server Health" + - Then "🔐 Authentication" → "Login with Seed User" + - Explore other endpoints + +## Sample Credentials + +Use these credentials for testing (created by seed script): + +``` +Username: johndoe +Email: john.doe@example.com +Password: password123 +``` + +Other available users: janesmith, bobwilson, alicejohnson, charliebrown + +## Variable Usage + +The collection uses these variables (automatically populated): + +| Variable | Purpose | Auto-filled | +|----------|---------|-------------| +| `{{base_url}}` | API server URL | No (default: localhost:3000) | +| `{{jwt_token}}` | Authentication token | Yes (after login) | +| `{{user_id}}` | Current user ID | Yes (after login) | +| `{{challenge_id}}` | Challenge being tested | Yes (after creating challenge) | +| `{{member_id}}` | Challenge membership ID | Yes (after joining challenge) | + +## Testing Workflow + +``` +1. Health Check ✓ + ↓ +2. Login → JWT token saved + ↓ +3. Create Challenge → challenge_id saved (optional) + ↓ +4. Join Challenge → member_id saved (optional) + ↓ +5. Dashboard endpoints + ↓ +6. LeetCode endpoints +``` diff --git a/postman/postman_environment.json b/postman/postman_environment.json new file mode 100644 index 0000000..4f75ef0 --- /dev/null +++ b/postman/postman_environment.json @@ -0,0 +1,44 @@ +{ + "id": "codeduel-env", + "name": "CodeDuel Development Environment", + "values": [ + { + "key": "base_url", + "value": "http://localhost:3000", + "enabled": true + }, + { + "key": "jwt_token", + "value": "", + "enabled": true + }, + { + "key": "user_id", + "value": "", + "enabled": true + }, + { + "key": "challenge_id", + "value": "", + "enabled": true + }, + { + "key": "member_id", + "value": "", + "enabled": true + }, + { + "key": "api_timeout", + "value": "5000", + "enabled": true + }, + { + "key": "content_type", + "value": "application/json", + "enabled": true + } + ], + "_postman_variable_scope": "environment", + "_postman_exported_at": "2026-02-26T00:00:00.000Z", + "_postman_exported_using": "Postman/11.0.0" +} diff --git a/prisma/seed.js b/prisma/seed.js new file mode 100644 index 0000000..e720a75 --- /dev/null +++ b/prisma/seed.js @@ -0,0 +1,411 @@ +const { PrismaClient } = require("@prisma/client"); +const bcryptjs = require("bcryptjs"); + +const prisma = new PrismaClient(); + +// Sample data +const USERS = [ + { + email: "john.doe@example.com", + username: "johndoe", + password: "password123", + leetcodeUsername: "john_doe", + }, + { + email: "jane.smith@example.com", + username: "janesmith", + password: "password123", + leetcodeUsername: "jane_smith", + }, + { + email: "bob.wilson@example.com", + username: "bobwilson", + password: "password123", + leetcodeUsername: "bob_wilson", + }, + { + email: "alice.johnson@example.com", + username: "alicejohnson", + password: "password123", + leetcodeUsername: "alice_johnson", + }, + { + email: "charlie.brown@example.com", + username: "charliebrown", + password: "password123", + leetcodeUsername: "charlie_brown", + }, +]; + +const PROBLEM_METADATA = [ + { + titleSlug: "two-sum", + questionId: "1", + title: "Two Sum", + difficulty: "Easy", + acRate: 48.5, + likes: 32000, + dislikes: 1000, + isPaidOnly: false, + topicTags: ["Array", "Hash Table"], + }, + { + titleSlug: "add-two-numbers", + questionId: "2", + title: "Add Two Numbers", + difficulty: "Medium", + acRate: 34.2, + likes: 18000, + dislikes: 4000, + isPaidOnly: false, + topicTags: ["Math", "Linked List"], + }, + { + titleSlug: "longest-substring-without-repeating-characters", + questionId: "3", + title: "Longest Substring Without Repeating Characters", + difficulty: "Medium", + acRate: 35.5, + likes: 16000, + dislikes: 700, + isPaidOnly: false, + topicTags: ["Hash Table", "Sliding Window", "String"], + }, + { + titleSlug: "median-of-two-sorted-arrays", + questionId: "4", + title: "Median of Two Sorted Arrays", + difficulty: "Hard", + acRate: 29.1, + likes: 13000, + dislikes: 2000, + isPaidOnly: false, + topicTags: ["Array", "Binary Search", "Divide and Conquer"], + }, + { + titleSlug: "palindrome-number", + questionId: "9", + title: "Palindrome Number", + difficulty: "Easy", + acRate: 52.0, + likes: 8000, + dislikes: 2000, + isPaidOnly: false, + topicTags: ["Math"], + }, + { + titleSlug: "container-with-most-water", + questionId: "11", + title: "Container With Most Water", + difficulty: "Medium", + acRate: 54.0, + likes: 15000, + dislikes: 800, + isPaidOnly: false, + topicTags: ["Array", "Two Pointers", "Greedy"], + }, + { + titleSlug: "merge-sorted-array", + questionId: "88", + title: "Merge Sorted Array", + difficulty: "Easy", + acRate: 58.0, + likes: 12000, + dislikes: 4000, + isPaidOnly: false, + topicTags: ["Array", "Two Pointers", "Sorting"], + }, + { + titleSlug: "search-in-rotated-sorted-array", + questionId: "33", + title: "Search in Rotated Sorted Array", + difficulty: "Medium", + acRate: 42.0, + likes: 17000, + dislikes: 1000, + isPaidOnly: false, + topicTags: ["Array", "Binary Search"], + }, + { + titleSlug: "word-ladder", + questionId: "127", + title: "Word Ladder", + difficulty: "Hard", + acRate: 38.5, + likes: 9000, + dislikes: 2000, + isPaidOnly: false, + topicTags: ["BFS", "Breadth-First Search", "Graph"], + }, + { + titleSlug: "regular-expression-matching", + questionId: "10", + title: "Regular Expression Matching", + difficulty: "Hard", + acRate: 27.5, + likes: 7000, + dislikes: 1500, + isPaidOnly: false, + topicTags: ["String", "Dynamic Programming", "Recursion"], + }, +]; + +/** + * Main seeding function + */ +async function main() { + console.log("🌱 Starting database seed..."); + + try { + // Clear existing data (in correct order due to foreign keys) + console.log("🗑️ Clearing existing data..."); + await prisma.penaltyLedger.deleteMany(); + await prisma.dailyResult.deleteMany(); + await prisma.challengeMember.deleteMany(); + await prisma.challenge.deleteMany(); + await prisma.user.deleteMany(); + await prisma.problemMetadata.deleteMany(); + + // 1. Create Users + console.log("👥 Creating users..."); + const users = await Promise.all( + USERS.map(async (user) => { + const hashedPassword = await bcryptjs.hash(user.password, 10); + return prisma.user.create({ + data: { + email: user.email, + username: user.username, + password: hashedPassword, + leetcodeUsername: user.leetcodeUsername, + emailPreferences: { + welcomeEmail: true, + streakReminder: true, + streakBroken: true, + weeklySummary: true, + }, + }, + }); + }) + ); + console.log(`✅ Created ${users.length} users`); + + // 2. Create Problem Metadata + console.log("📚 Creating problem metadata..."); + const problems = await Promise.all( + PROBLEM_METADATA.map((problem) => + prisma.problemMetadata.create({ + data: problem, + }) + ) + ); + console.log(`✅ Created ${problems.length} problems`); + + // 3. Create Challenges + console.log("🎯 Creating challenges..."); + const now = new Date(); + const startDate = new Date(now.getTime() - 7 * 24 * 60 * 60 * 1000); // 7 days ago + const endDate = new Date(now.getTime() + 23 * 24 * 60 * 60 * 1000); // 23 days from now + + const challenges = [ + { + name: "LeetCode Easy Challenges March 2026", + description: + "A series of easy-level coding problems to warm up your skills", + ownerId: users[0].id, + minSubmissionsPerDay: 1, + difficultyFilter: ["Easy"], + uniqueProblemConstraint: true, + penaltyAmount: 0, + startDate: new Date(startDate), + endDate: new Date(endDate), + status: "ACTIVE", + visibility: "PUBLIC", + }, + { + name: "LeetCode Medium Marathon", + description: + "Challenge yourself with medium-level problems for 30 days", + ownerId: users[1].id, + minSubmissionsPerDay: 2, + difficultyFilter: ["Medium"], + uniqueProblemConstraint: true, + penaltyAmount: 5, + startDate: new Date(startDate), + endDate: new Date(endDate), + status: "ACTIVE", + visibility: "PUBLIC", + }, + { + name: "Hard Problem Weekend", + description: "Tackle the hardest problems every weekend", + ownerId: users[0].id, + minSubmissionsPerDay: 1, + difficultyFilter: ["Hard"], + uniqueProblemConstraint: false, + penaltyAmount: 10, + startDate: new Date(now), + endDate: new Date(now.getTime() + 30 * 24 * 60 * 60 * 1000), + status: "PENDING", + visibility: "PRIVATE", + }, + { + name: "Beginner's Journey", + description: "A comprehensive challenge for those starting their coding journey", + ownerId: users[2].id, + minSubmissionsPerDay: 1, + difficultyFilter: ["Easy", "Medium"], + uniqueProblemConstraint: true, + penaltyAmount: 2, + startDate: new Date(startDate), + endDate: new Date(endDate), + status: "ACTIVE", + visibility: "PUBLIC", + }, + { + name: "All-In January Challenge", + description: "No difficulty limits - solve problems of any level", + ownerId: users[3].id, + minSubmissionsPerDay: 3, + difficultyFilter: ["Easy", "Medium", "Hard"], + uniqueProblemConstraint: true, + penaltyAmount: 15, + startDate: new Date(startDate), + endDate: new Date(endDate), + status: "COMPLETED", + visibility: "PUBLIC", + }, + ]; + + const createdChallenges = await Promise.all( + challenges.map((challenge) => prisma.challenge.create({ data: challenge })) + ); + console.log(`✅ Created ${createdChallenges.length} challenges`); + + // 4. Create Challenge Members + console.log("👫 Creating challenge memberships..."); + const memberships = []; + + // Users join challenges (not their own) + for (let i = 0; i < createdChallenges.length; i++) { + const challenge = createdChallenges[i]; + for (let j = 0; j < users.length; j++) { + const user = users[j]; + // Don't add owner twice, add others randomly + if (user.id !== challenge.ownerId) { + if (Math.random() > 0.3) { + // 70% chance to join + const membership = await prisma.challengeMember.create({ + data: { + challengeId: challenge.id, + userId: user.id, + currentStreak: Math.floor(Math.random() * 10), + longestStreak: Math.floor(Math.random() * 25), + totalPenalties: Math.random() * 50, + isActive: Math.random() > 0.2, // 80% active + }, + }); + memberships.push(membership); + } + } + } + } + console.log(`✅ Created ${memberships.length} challenge memberships`); + + // 5. Create Daily Results + console.log("📊 Creating daily results..."); + const dailyResults = []; + + for (const membership of memberships) { + // Create random daily results for the last 7 days + for (let daysAgo = 0; daysAgo < 7; daysAgo++) { + const resultDate = new Date(now); + resultDate.setDate(resultDate.getDate() - daysAgo); + resultDate.setHours(0, 0, 0, 0); + + const completed = Math.random() > 0.3; // 70% completion rate + const result = await prisma.dailyResult.create({ + data: { + challengeId: membership.challengeId, + memberId: membership.id, + date: resultDate, + completed: completed, + submissionsCount: completed ? Math.floor(Math.random() * 5) + 1 : 0, + problemsSolved: completed + ? [ + problems[Math.floor(Math.random() * problems.length)] + .titleSlug, + ] + : [], + evaluatedAt: completed ? new Date() : null, + metadata: { + submissionDetails: + completed ? Math.floor(Math.random() * 10) + 1 : null, + timeSpent: completed ? Math.floor(Math.random() * 120) : null, + }, + }, + }); + dailyResults.push(result); + } + } + console.log(`✅ Created ${dailyResults.length} daily results`); + + // 6. Create Penalty Ledger entries + console.log("⚠️ Creating penalty ledger entries..."); + const penaltyLedgerEntries = []; + + for (const membership of memberships.slice(0, Math.floor(memberships.length * 0.5))) { + // Only some members have penalties + const penaltyCount = Math.floor(Math.random() * 3); // 0-2 penalties + for (let i = 0; i < penaltyCount; i++) { + const penaltyDate = new Date(now); + penaltyDate.setDate(penaltyDate.getDate() - Math.floor(Math.random() * 7)); + penaltyDate.setHours(0, 0, 0, 0); + + const reasons = [ + "Missed daily submission", + "Failed to meet minimum submissions", + "Late submission", + "Inactivity penalty", + ]; + + const penalty = await prisma.penaltyLedger.create({ + data: { + memberId: membership.id, + amount: Math.random() * 20 + 5, + reason: reasons[Math.floor(Math.random() * reasons.length)], + date: penaltyDate, + }, + }); + penaltyLedgerEntries.push(penalty); + } + } + console.log(`✅ Created ${penaltyLedgerEntries.length} penalty ledger entries`); + + // Summary + console.log("\n✅ Database seed completed successfully!"); + console.log("\n📊 Summary:"); + console.log(` • Users: ${users.length}`); + console.log(` • Problems: ${problems.length}`); + console.log(` • Challenges: ${createdChallenges.length}`); + console.log(` • Challenge Members: ${memberships.length}`); + console.log(` • Daily Results: ${dailyResults.length}`); + console.log(` • Penalty Ledger Entries: ${penaltyLedgerEntries.length}`); + + console.log("\n📝 Sample Credentials for Testing:"); + users.forEach((user, index) => { + console.log(` ${index + 1}. ${user.username} / ${user.password}`); + }); + } catch (error) { + console.error("❌ Error during seeding:", error); + throw error; + } finally { + await prisma.$disconnect(); + } +} + +// Execute seeding +main() + .catch((error) => { + console.error(error); + process.exit(1); + }); From fbeea99e5073abbfaece185aebb80bf23ddb8eff Mon Sep 17 00:00:00 2001 From: Aaleya Boxwala Date: Sat, 28 Feb 2026 16:38:43 +0530 Subject: [PATCH 7/9] fixed authcontroller.js bugs --- src/controllers/auth.controller.js | 36 +++++++++++++++++++++++++----- src/services/auth.service.js | 2 +- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/src/controllers/auth.controller.js b/src/controllers/auth.controller.js index fa38edb..d46f84b 100644 --- a/src/controllers/auth.controller.js +++ b/src/controllers/auth.controller.js @@ -36,7 +36,7 @@ const validateLogin = [ ]; /** -<<<<<<< HEAD + * Validation middleware for forgot password */ const validateForgotPassword = [ @@ -54,7 +54,8 @@ const validateResetPassword = [ body("newPassword") .isLength({ min: 6 }) .withMessage("New password must be at least 6 characters"), -======= + +/** * Validation middleware for profile update */ const validateUpdateProfile = [ @@ -72,9 +73,29 @@ const validateUpdateProfile = [ .if(body("newPassword").exists({ checkFalsy: true })) .notEmpty() .withMessage("Current password is required when setting a new password"), ->>>>>>> c52549d (fix/profile-validation-null-safety) ]; +/** + * Validation middleware for forgot password + */ +const validateForgotPassword = [ + body("email") + .isEmail() + .normalizeEmail() + .withMessage("Valid email is required"), +]; + +/** + * Validation middleware for reset password + */ +const validateResetPassword = [ + body("token").notEmpty().withMessage("Reset token is required"), + body("newPassword") + .isLength({ min: 6 }) + .withMessage("New password must be at least 6 characters"), +]; + + /** * Register a new user * POST /api/auth/register @@ -226,14 +247,17 @@ module.exports = { login, getProfile, updateProfile, + validateRegister, validateLogin, -<<<<<<< HEAD + forgotPassword, resetPassword, + validateRegister, + validateLogin, validateForgotPassword, validateResetPassword, -======= validateUpdateProfile, ->>>>>>> c52549d (fix/profile-validation-null-safety) + }; + diff --git a/src/services/auth.service.js b/src/services/auth.service.js index 5248e21..68b2982 100644 --- a/src/services/auth.service.js +++ b/src/services/auth.service.js @@ -317,6 +317,6 @@ module.exports = { forgotPassword, resetPassword, - + }; From 51f62a068cfcbaa9730fe745f759f73b12a698c5 Mon Sep 17 00:00:00 2001 From: PrinceDiyora Date: Fri, 27 Feb 2026 14:43:13 +0530 Subject: [PATCH 8/9] feat: Implement challenge invite feature with validation and invite code generation --- prisma/schema.prisma | 33 ++++++ src/controllers/challenge.controller.js | 69 +++++++++++ src/routes/challenge.routes.js | 23 ++++ src/services/challenge.service.js | 151 ++++++++++++++++++++++++ 4 files changed, 276 insertions(+) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index a607506..98f3c0a 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -47,10 +47,17 @@ model User { // Relations + dailySubmissions DailySubmission[] @relation("UserDailySubmissions") ownedChallenges Challenge[] @relation("ChallengeOwner") memberships ChallengeMember[] + + ownedChallenges Challenge[] @relation("ChallengeOwner") + memberships ChallengeMember[] + challengeInvites ChallengeInvite[] @relation("InviteCreator") + + @@map("users") } @@ -67,10 +74,17 @@ model Challenge { updatedAt DateTime @updatedAt // Relations + owner User @relation("ChallengeOwner", fields: [ownerId], references: [id], onDelete: Cascade) dailySubmissions DailySubmission[] @relation("ChallengeDailySubmissions") members ChallengeMember[] + owner User @relation("ChallengeOwner", fields: [ownerId], references: [id], onDelete: Cascade) + members ChallengeMember[] + dailyResults DailyResult[] + invites ChallengeInvite[] + + @@map("challenges") } @@ -153,6 +167,25 @@ model ProblemMetadata { @@map("problem_metadata") } +model ChallengeInvite { + id String @id @default(uuid()) + challengeId String + code String @unique + createdBy String + expiresAt DateTime + maxUses Int @default(1) + usedCount Int @default(0) + createdAt DateTime @default(now()) + + // Relations + challenge Challenge @relation(fields: [challengeId], references: [id], onDelete: Cascade) + creator User @relation("InviteCreator", fields: [createdBy], references: [id]) + + @@index([code]) + @@index([challengeId]) + @@map("challenge_invites") +} + enum ChallengeStatus { PENDING ACTIVE diff --git a/src/controllers/challenge.controller.js b/src/controllers/challenge.controller.js index 871ae2e..4b10a46 100644 --- a/src/controllers/challenge.controller.js +++ b/src/controllers/challenge.controller.js @@ -147,6 +147,72 @@ const updateChallengeStatus = asyncHandler(async (req, res) => { }); }); +/** + * Validation middleware for generating invite code + */ +const validateGenerateInvite = [ + body("expiresInHours") + .optional() + .isInt({ min: 1, max: 168 }) + .withMessage("Expiry must be between 1 and 168 hours (7 days)"), + body("maxUses") + .optional() + .isInt({ min: 1, max: 100 }) + .withMessage("Max uses must be between 1 and 100"), +]; + +/** + * Generate an invite code for a challenge + * POST /api/challenges/:id/invite + */ +const generateInviteCode = asyncHandler(async (req, res) => { + const errors = validationResult(req); + if (!errors.isEmpty()) { + return res.status(400).json({ + success: false, + message: "Validation failed", + errors: errors.array(), + }); + } + + const { id } = req.params; + const { expiresInHours, maxUses } = req.body; + + const invite = await challengeService.generateInviteCode(req.user.id, id, { + expiresInHours, + maxUses, + }); + + res.status(201).json({ + success: true, + message: "Invite code generated successfully", + data: invite, + }); +}); + +/** + * Join a challenge using an invite code + * POST /api/challenges/join-by-code + */ +const joinByInviteCode = asyncHandler(async (req, res) => { + const { code } = req.body; + + if (!code) { + return res.status(400).json({ + success: false, + message: "Invite code is required", + }); + } + + const membership = await challengeService.joinByInviteCode(req.user.id, code); + + res.status(200).json({ + success: true, + message: "Successfully joined the challenge via invite code", + data: membership, + }); +}); + module.exports = { createChallenge, getChallengeById, @@ -154,4 +220,7 @@ module.exports = { getUserChallenges, updateChallengeStatus, validateCreateChallenge, + generateInviteCode, + joinByInviteCode, + validateGenerateInvite, }; diff --git a/src/routes/challenge.routes.js b/src/routes/challenge.routes.js index 5f5d741..ebc736b 100644 --- a/src/routes/challenge.routes.js +++ b/src/routes/challenge.routes.js @@ -15,6 +15,17 @@ router.post( challengeController.createChallenge ); +/** + * @route POST /api/challenges/join-by-code + * @desc Join a challenge using an invite code + * @access Private + */ +router.post( + "/join-by-code", + authenticate, + challengeController.joinByInviteCode +); + /** * @route GET /api/challenges * @desc Get all challenges for current user @@ -36,6 +47,18 @@ router.get("/:id", authenticate, challengeController.getChallengeById); */ router.post("/:id/join", authenticate, challengeController.joinChallenge); +/** + * @route POST /api/challenges/:id/invite + * @desc Generate an invite code for a challenge (owner only) + * @access Private + */ +router.post( + "/:id/invite", + authenticate, + challengeController.validateGenerateInvite, + challengeController.generateInviteCode +); + /** * @route PATCH /api/challenges/:id/status * @desc Update challenge status (owner only) diff --git a/src/services/challenge.service.js b/src/services/challenge.service.js index e0c74e3..abd855d 100644 --- a/src/services/challenge.service.js +++ b/src/services/challenge.service.js @@ -348,10 +348,161 @@ const updateChallengeStatus = async (challengeId, userId, newStatus) => { return updatedChallenge; }; +/** + * Generate an invite code for a challenge (owner only) + * @param {string} userId - User ID (must be owner) + * @param {string} challengeId - Challenge ID + * @param {Object} options - Invite options + * @param {number} options.expiresInHours - Hours until expiry (default: 24) + * @param {number} options.maxUses - Maximum number of uses (default: 1) + * @returns {Object} Created invite with code + */ +const generateInviteCode = async (userId, challengeId, options = {}) => { + const { expiresInHours = 24, maxUses = 1 } = options; + + // Verify challenge exists + const challenge = await prisma.challenge.findUnique({ + where: { id: challengeId }, + }); + + if (!challenge) { + throw new AppError("Challenge not found", 404); + } + + // Verify user is the owner + if (challenge.ownerId !== userId) { + throw new AppError("Only the challenge owner can generate invite codes", 403); + } + + // Generate cryptographically random code + const crypto = require("crypto"); + const code = crypto.randomBytes(6).toString("base64url").substring(0, 8).toUpperCase(); + + // Calculate expiry + const expiresAt = new Date(Date.now() + expiresInHours * 60 * 60 * 1000); + + // Create invite record + const invite = await prisma.challengeInvite.create({ + data: { + challengeId, + code, + createdBy: userId, + expiresAt, + maxUses, + }, + }); + + logger.info( + `Invite code generated for challenge ${challenge.name} by owner. Code: ${code}, Expires: ${expiresAt.toISOString()}, Max uses: ${maxUses}` + ); + + return { + code: invite.code, + expiresAt: invite.expiresAt, + maxUses: invite.maxUses, + challengeId: invite.challengeId, + }; +}; + +/** + * Join a challenge using an invite code + * @param {string} userId - User ID + * @param {string} code - Invite code + * @returns {Object} Challenge membership + */ +const joinByInviteCode = async (userId, code) => { + // Find the invite by code + const invite = await prisma.challengeInvite.findUnique({ + where: { code }, + include: { + challenge: { + select: { + id: true, + name: true, + status: true, + }, + }, + }, + }); + + if (!invite) { + throw new AppError("Invalid invite code", 404); + } + + // Check if code has expired + if (invite.expiresAt < new Date()) { + throw new AppError("Invite code has expired", 400); + } + + // Check if code has reached max uses + if (invite.usedCount >= invite.maxUses) { + throw new AppError("Invite code has reached its maximum usage limit", 400); + } + + // Check if challenge is still joinable + if (invite.challenge.status === "COMPLETED" || invite.challenge.status === "CANCELLED") { + throw new AppError("Cannot join a completed or cancelled challenge", 400); + } + + // Check if already a member + const existingMembership = await prisma.challengeMember.findUnique({ + where: { + challengeId_userId: { + challengeId: invite.challengeId, + userId, + }, + }, + }); + + if (existingMembership) { + throw new AppError("Already a member of this challenge", 400); + } + + // Atomically: increment usedCount + create membership + const [updatedInvite, membership] = await prisma.$transaction([ + prisma.challengeInvite.update({ + where: { code }, + data: { + usedCount: { increment: 1 }, + }, + }), + prisma.challengeMember.create({ + data: { + challengeId: invite.challengeId, + userId, + }, + include: { + challenge: { + select: { + id: true, + name: true, + startDate: true, + endDate: true, + }, + }, + user: { + select: { + id: true, + username: true, + }, + }, + }, + }), + ]); + + logger.info( + `User ${membership.user.username} joined challenge ${membership.challenge.name} via invite code ${code}` + ); + + return membership; +}; + module.exports = { createChallenge, getChallengeById, joinChallenge, getUserChallenges, updateChallengeStatus, + generateInviteCode, + joinByInviteCode, }; From 02d30717225ca47f6d5f87f5ce91db24f7bf483f Mon Sep 17 00:00:00 2001 From: tarun-baranwal Date: Sun, 1 Mar 2026 00:40:45 +0530 Subject: [PATCH 9/9] Remove package-lock.json from PR --- .gitignore | Bin 430 -> 516 bytes package-lock.json | 1881 --------------------------------------------- 2 files changed, 1881 deletions(-) delete mode 100644 package-lock.json diff --git a/.gitignore b/.gitignore index 407075bc46dd60e748f28f4e0f79caf090c66e51..ca2d965f4a089b6711818214b7bc8fca62a99d4d 100644 GIT binary patch literal 516 zcmZWl!D_=W4E5RIe+cweX!;MMJq!jLYwyLewai;=8QD(hW#2w2=?-NVKk4b^=|!9F z02z{p z7w;=F{H)^F6Dtm<%c&xP(dW+=htm6Doj$cN`EGSL+J_=L1|b<`*BgZrCI5o^7)G*k v0r?r3pCM)>OSkSLEJv;}^Qbb-kd;+Vee*jiP&+j#T>4&psls(qMrrj6;v$v& literal 430 zcmZWl!A`?4488j+D(yCj_8+G0fP@5MyH9CjibZ2bPExcB-;UjJ0CBNnzo++Jyz7pb zkt6a%Sb!zsHA!p>mH{}YhlpdF`$gtG+=BAI8C6B^IPAI;ucX2Wxpr$%3Zn@@kGyWh zcvD#J&xk87lAZc{U9tR`vs#*|lJF19T%KeuV3921-mSrQuZ=4u>|&?^GQ|zEZj6HH z%?6kFaQ4Mqh-a8&MGZ3!(DQA&N~^im!5NRo6ZC7D>>vhG#NcM-GjCO3|K+UbGxW#v z^;|^}F7GXkrH`W{hek{6?t&1hnCj@OP5ecvB#XJVA)No*Q+TH HP|@o*hKP*o diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index c8e169c..0000000 --- a/package-lock.json +++ /dev/null @@ -1,1881 +0,0 @@ -{ - "name": "leetcode-challenge-tracker", - "version": "1.0.0", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "leetcode-challenge-tracker", - "version": "1.0.0", - "license": "ISC", - "dependencies": { - "@prisma/client": "^5.22.0", - "axios": "^1.6.5", - "bcryptjs": "^2.4.3", - "cors": "^2.8.5", - "dotenv": "^16.3.1", - "express": "^4.18.2", - "express-rate-limit": "^8.2.1", - "express-validator": "^7.3.1", - "jsonwebtoken": "^9.0.2", - "node-cron": "^3.0.3", - "nodemailer": "^8.0.1", - "prisma": "^5.22.0", - "winston": "^3.11.0" - }, - "devDependencies": { - "nodemon": "^3.0.2" - } - }, - "node_modules/@colors/colors": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@colors/colors/-/colors-1.6.0.tgz", - "integrity": "sha512-Ir+AOibqzrIsL6ajt3Rz3LskB7OiMVHqltZmspbW/TJuTVuyOMirVqAkjfY6JISiLHgyNqicAC8AyHHGzNd/dA==", - "license": "MIT", - "engines": { - "node": ">=0.1.90" - } - }, - "node_modules/@dabh/diagnostics": { - "version": "2.0.8", - "resolved": "https://registry.npmjs.org/@dabh/diagnostics/-/diagnostics-2.0.8.tgz", - "integrity": "sha512-R4MSXTVnuMzGD7bzHdW2ZhhdPC/igELENcq5IjEverBvq5hn1SXCWcsi6eSsdWP0/Ur+SItRRjAktmdoX/8R/Q==", - "license": "MIT", - "dependencies": { - "@so-ric/colorspace": "^1.1.6", - "enabled": "2.0.x", - "kuler": "^2.0.0" - } - }, - "node_modules/@prisma/client": { - "version": "5.22.0", - "resolved": "https://registry.npmjs.org/@prisma/client/-/client-5.22.0.tgz", - "integrity": "sha512-M0SVXfyHnQREBKxCgyo7sffrKttwE6R8PMq330MIUF0pTwjUhLbW84pFDlf06B27XyCR++VtjugEnIHdr07SVA==", - "hasInstallScript": true, - "engines": { - "node": ">=16.13" - }, - "peerDependencies": { - "prisma": "*" - }, - "peerDependenciesMeta": { - "prisma": { - "optional": true - } - } - }, - "node_modules/@prisma/debug": { - "version": "5.22.0", - "resolved": "https://registry.npmjs.org/@prisma/debug/-/debug-5.22.0.tgz", - "integrity": "sha512-AUt44v3YJeggO2ZU5BkXI7M4hu9BF2zzH2iF2V5pyXT/lRTyWiElZ7It+bRH1EshoMRxHgpYg4VB6rCM+mG5jQ==" - }, - "node_modules/@prisma/engines": { - "version": "5.22.0", - "resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-5.22.0.tgz", - "integrity": "sha512-UNjfslWhAt06kVL3CjkuYpHAWSO6L4kDCVPegV6itt7nD1kSJavd3vhgAEhjglLJJKEdJ7oIqDJ+yHk6qO8gPA==", - "hasInstallScript": true, - "dependencies": { - "@prisma/debug": "5.22.0", - "@prisma/engines-version": "5.22.0-44.605197351a3c8bdd595af2d2a9bc3025bca48ea2", - "@prisma/fetch-engine": "5.22.0", - "@prisma/get-platform": "5.22.0" - } - }, - "node_modules/@prisma/engines-version": { - "version": "5.22.0-44.605197351a3c8bdd595af2d2a9bc3025bca48ea2", - "resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-5.22.0-44.605197351a3c8bdd595af2d2a9bc3025bca48ea2.tgz", - "integrity": "sha512-2PTmxFR2yHW/eB3uqWtcgRcgAbG1rwG9ZriSvQw+nnb7c4uCr3RAcGMb6/zfE88SKlC1Nj2ziUvc96Z379mHgQ==" - }, - "node_modules/@prisma/fetch-engine": { - "version": "5.22.0", - "resolved": "https://registry.npmjs.org/@prisma/fetch-engine/-/fetch-engine-5.22.0.tgz", - "integrity": "sha512-bkrD/Mc2fSvkQBV5EpoFcZ87AvOgDxbG99488a5cexp5Ccny+UM6MAe/UFkUC0wLYD9+9befNOqGiIJhhq+HbA==", - "dependencies": { - "@prisma/debug": "5.22.0", - "@prisma/engines-version": "5.22.0-44.605197351a3c8bdd595af2d2a9bc3025bca48ea2", - "@prisma/get-platform": "5.22.0" - } - }, - "node_modules/@prisma/get-platform": { - "version": "5.22.0", - "resolved": "https://registry.npmjs.org/@prisma/get-platform/-/get-platform-5.22.0.tgz", - "integrity": "sha512-pHhpQdr1UPFpt+zFfnPazhulaZYCUqeIcPpJViYoq9R+D/yw4fjE+CtnsnKzPYm0ddUbeXUzjGVGIRVgPDCk4Q==", - "dependencies": { - "@prisma/debug": "5.22.0" - } - }, - "node_modules/@so-ric/colorspace": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/@so-ric/colorspace/-/colorspace-1.1.6.tgz", - "integrity": "sha512-/KiKkpHNOBgkFJwu9sh48LkHSMYGyuTcSFK/qMBdnOAlrRJzRSXAOFB5qwzaVQuDl8wAvHVMkaASQDReTahxuw==", - "license": "MIT", - "dependencies": { - "color": "^5.0.2", - "text-hex": "1.0.x" - } - }, - "node_modules/@types/triple-beam": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/@types/triple-beam/-/triple-beam-1.3.5.tgz", - "integrity": "sha512-6WaYesThRMCl19iryMYP7/x2OVgCtbIVflDGFpWnb9irXI3UjYE4AzmYuiUKY1AJstGijoY+MgUszMgRxIYTYw==", - "license": "MIT" - }, - "node_modules/accepts": { - "version": "1.3.8", - "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", - "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", - "license": "MIT", - "dependencies": { - "mime-types": "~2.1.34", - "negotiator": "0.6.3" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/anymatch": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", - "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", - "dev": true, - "license": "ISC", - "dependencies": { - "normalize-path": "^3.0.0", - "picomatch": "^2.0.4" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/array-flatten": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", - "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==", - "license": "MIT" - }, - "node_modules/async": { - "version": "3.2.6", - "resolved": "https://registry.npmjs.org/async/-/async-3.2.6.tgz", - "integrity": "sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==", - "license": "MIT" - }, - "node_modules/asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", - "license": "MIT" - }, - "node_modules/axios": { - "version": "1.13.2", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.13.2.tgz", - "integrity": "sha512-VPk9ebNqPcy5lRGuSlKx752IlDatOjT9paPlm8A7yOuW2Fbvp4X3JznJtT4f0GzGLLiWE9W8onz51SqLYwzGaA==", - "license": "MIT", - "dependencies": { - "follow-redirects": "^1.15.6", - "form-data": "^4.0.4", - "proxy-from-env": "^1.1.0" - } - }, - "node_modules/balanced-match": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", - "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "dev": true, - "license": "MIT" - }, - "node_modules/bcryptjs": { - "version": "2.4.3", - "resolved": "https://registry.npmjs.org/bcryptjs/-/bcryptjs-2.4.3.tgz", - "integrity": "sha512-V/Hy/X9Vt7f3BbPJEi8BdVFMByHi+jNXrYkW3huaybV/kQ0KJg0Y6PkEMbn+zeT+i+SiKZ/HMqJGIIt4LZDqNQ==", - "license": "MIT" - }, - "node_modules/binary-extensions": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", - "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/body-parser": { - "version": "1.20.4", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.4.tgz", - "integrity": "sha512-ZTgYYLMOXY9qKU/57FAo8F+HA2dGX7bqGc71txDRC1rS4frdFI5R7NhluHxH6M0YItAP0sHB4uqAOcYKxO6uGA==", - "license": "MIT", - "dependencies": { - "bytes": "~3.1.2", - "content-type": "~1.0.5", - "debug": "2.6.9", - "depd": "2.0.0", - "destroy": "~1.2.0", - "http-errors": "~2.0.1", - "iconv-lite": "~0.4.24", - "on-finished": "~2.4.1", - "qs": "~6.14.0", - "raw-body": "~2.5.3", - "type-is": "~1.6.18", - "unpipe": "~1.0.0" - }, - "engines": { - "node": ">= 0.8", - "npm": "1.2.8000 || >= 1.4.16" - } - }, - "node_modules/brace-expansion": { - "version": "1.1.12", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", - "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", - "dev": true, - "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "node_modules/braces": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", - "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", - "dev": true, - "license": "MIT", - "dependencies": { - "fill-range": "^7.1.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/buffer-equal-constant-time": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", - "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==", - "license": "BSD-3-Clause" - }, - "node_modules/bytes": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", - "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/call-bind-apply-helpers": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", - "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", - "license": "MIT", - "dependencies": { - "es-errors": "^1.3.0", - "function-bind": "^1.1.2" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/call-bound": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", - "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", - "license": "MIT", - "dependencies": { - "call-bind-apply-helpers": "^1.0.2", - "get-intrinsic": "^1.3.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/chokidar": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", - "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", - "dev": true, - "license": "MIT", - "dependencies": { - "anymatch": "~3.1.2", - "braces": "~3.0.2", - "glob-parent": "~5.1.2", - "is-binary-path": "~2.1.0", - "is-glob": "~4.0.1", - "normalize-path": "~3.0.0", - "readdirp": "~3.6.0" - }, - "engines": { - "node": ">= 8.10.0" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - }, - "optionalDependencies": { - "fsevents": "~2.3.2" - } - }, - "node_modules/color": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/color/-/color-5.0.3.tgz", - "integrity": "sha512-ezmVcLR3xAVp8kYOm4GS45ZLLgIE6SPAFoduLr6hTDajwb3KZ2F46gulK3XpcwRFb5KKGCSezCBAY4Dw4HsyXA==", - "license": "MIT", - "dependencies": { - "color-convert": "^3.1.3", - "color-string": "^2.1.3" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/color-convert": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-3.1.3.tgz", - "integrity": "sha512-fasDH2ont2GqF5HpyO4w0+BcewlhHEZOFn9c1ckZdHpJ56Qb7MHhH/IcJZbBGgvdtwdwNbLvxiBEdg336iA9Sg==", - "license": "MIT", - "dependencies": { - "color-name": "^2.0.0" - }, - "engines": { - "node": ">=14.6" - } - }, - "node_modules/color-name": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-2.1.0.tgz", - "integrity": "sha512-1bPaDNFm0axzE4MEAzKPuqKWeRaT43U/hyxKPBdqTfmPF+d6n7FSoTFxLVULUJOmiLp01KjhIPPH+HrXZJN4Rg==", - "license": "MIT", - "engines": { - "node": ">=12.20" - } - }, - "node_modules/color-string": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/color-string/-/color-string-2.1.4.tgz", - "integrity": "sha512-Bb6Cq8oq0IjDOe8wJmi4JeNn763Xs9cfrBcaylK1tPypWzyoy2G3l90v9k64kjphl/ZJjPIShFztenRomi8WTg==", - "license": "MIT", - "dependencies": { - "color-name": "^2.0.0" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/combined-stream": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", - "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "license": "MIT", - "dependencies": { - "delayed-stream": "~1.0.0" - }, - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", - "dev": true, - "license": "MIT" - }, - "node_modules/content-disposition": { - "version": "0.5.4", - "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", - "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", - "license": "MIT", - "dependencies": { - "safe-buffer": "5.2.1" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/content-type": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", - "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/cookie": { - "version": "0.7.2", - "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", - "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/cookie-signature": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.7.tgz", - "integrity": "sha512-NXdYc3dLr47pBkpUCHtKSwIOQXLVn8dZEuywboCOJY/osA0wFSLlSawr3KN8qXJEyX66FcONTH8EIlVuK0yyFA==", - "license": "MIT" - }, - "node_modules/cors": { - "version": "2.8.5", - "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", - "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", - "license": "MIT", - "dependencies": { - "object-assign": "^4", - "vary": "^1" - }, - "engines": { - "node": ">= 0.10" - } - }, - "node_modules/debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "license": "MIT", - "dependencies": { - "ms": "2.0.0" - } - }, - "node_modules/delayed-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", - "license": "MIT", - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/depd": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", - "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/destroy": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", - "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", - "license": "MIT", - "engines": { - "node": ">= 0.8", - "npm": "1.2.8000 || >= 1.4.16" - } - }, - "node_modules/dotenv": { - "version": "16.6.1", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.6.1.tgz", - "integrity": "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==", - "license": "BSD-2-Clause", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://dotenvx.com" - } - }, - "node_modules/dunder-proto": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", - "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", - "license": "MIT", - "dependencies": { - "call-bind-apply-helpers": "^1.0.1", - "es-errors": "^1.3.0", - "gopd": "^1.2.0" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/ecdsa-sig-formatter": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", - "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", - "license": "Apache-2.0", - "dependencies": { - "safe-buffer": "^5.0.1" - } - }, - "node_modules/ee-first": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", - "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", - "license": "MIT" - }, - "node_modules/enabled": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/enabled/-/enabled-2.0.0.tgz", - "integrity": "sha512-AKrN98kuwOzMIdAizXGI86UFBoo26CL21UM763y1h/GMSJ4/OHU9k2YlsmBpyScFo/wbLzWQJBMCW4+IO3/+OQ==", - "license": "MIT" - }, - "node_modules/encodeurl": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", - "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/es-define-property": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", - "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/es-errors": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", - "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/es-object-atoms": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", - "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", - "license": "MIT", - "dependencies": { - "es-errors": "^1.3.0" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/es-set-tostringtag": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz", - "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==", - "license": "MIT", - "dependencies": { - "es-errors": "^1.3.0", - "get-intrinsic": "^1.2.6", - "has-tostringtag": "^1.0.2", - "hasown": "^2.0.2" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/escape-html": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", - "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", - "license": "MIT" - }, - "node_modules/etag": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", - "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/express": { - "version": "4.22.1", - "resolved": "https://registry.npmjs.org/express/-/express-4.22.1.tgz", - "integrity": "sha512-F2X8g9P1X7uCPZMA3MVf9wcTqlyNp7IhH5qPCI0izhaOIYXaW9L535tGA3qmjRzpH+bZczqq7hVKxTR4NWnu+g==", - "license": "MIT", - "dependencies": { - "accepts": "~1.3.8", - "array-flatten": "1.1.1", - "body-parser": "~1.20.3", - "content-disposition": "~0.5.4", - "content-type": "~1.0.4", - "cookie": "~0.7.1", - "cookie-signature": "~1.0.6", - "debug": "2.6.9", - "depd": "2.0.0", - "encodeurl": "~2.0.0", - "escape-html": "~1.0.3", - "etag": "~1.8.1", - "finalhandler": "~1.3.1", - "fresh": "~0.5.2", - "http-errors": "~2.0.0", - "merge-descriptors": "1.0.3", - "methods": "~1.1.2", - "on-finished": "~2.4.1", - "parseurl": "~1.3.3", - "path-to-regexp": "~0.1.12", - "proxy-addr": "~2.0.7", - "qs": "~6.14.0", - "range-parser": "~1.2.1", - "safe-buffer": "5.2.1", - "send": "~0.19.0", - "serve-static": "~1.16.2", - "setprototypeof": "1.2.0", - "statuses": "~2.0.1", - "type-is": "~1.6.18", - "utils-merge": "1.0.1", - "vary": "~1.1.2" - }, - "engines": { - "node": ">= 0.10.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/express-rate-limit": { - "version": "8.2.1", - "resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-8.2.1.tgz", - "integrity": "sha512-PCZEIEIxqwhzw4KF0n7QF4QqruVTcF73O5kFKUnGOyjbCCgizBBiFaYpd/fnBLUMPw/BWw9OsiN7GgrNYr7j6g==", - "dependencies": { - "ip-address": "10.0.1" - }, - "engines": { - "node": ">= 16" - }, - "funding": { - "url": "https://github.com/sponsors/express-rate-limit" - }, - "peerDependencies": { - "express": ">= 4.11" - } - }, - "node_modules/express-validator": { - "version": "7.3.1", - "resolved": "https://registry.npmjs.org/express-validator/-/express-validator-7.3.1.tgz", - "integrity": "sha512-IGenaSf+DnWc69lKuqlRE9/i/2t5/16VpH5bXoqdxWz1aCpRvEdrBuu1y95i/iL5QP8ZYVATiwLFhwk3EDl5vg==", - "dependencies": { - "lodash": "^4.17.21", - "validator": "~13.15.23" - }, - "engines": { - "node": ">= 8.0.0" - } - }, - "node_modules/fecha": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/fecha/-/fecha-4.2.3.tgz", - "integrity": "sha512-OP2IUU6HeYKJi3i0z4A19kHMQoLVs4Hc+DPqqxI2h/DPZHTm/vjsfC6P0b4jCMy14XizLBqvndQ+UilD7707Jw==", - "license": "MIT" - }, - "node_modules/fill-range": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", - "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", - "dev": true, - "license": "MIT", - "dependencies": { - "to-regex-range": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/finalhandler": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.2.tgz", - "integrity": "sha512-aA4RyPcd3badbdABGDuTXCMTtOneUCAYH/gxoYRTZlIJdF0YPWuGqiAsIrhNnnqdXGswYk6dGujem4w80UJFhg==", - "license": "MIT", - "dependencies": { - "debug": "2.6.9", - "encodeurl": "~2.0.0", - "escape-html": "~1.0.3", - "on-finished": "~2.4.1", - "parseurl": "~1.3.3", - "statuses": "~2.0.2", - "unpipe": "~1.0.0" - }, - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/fn.name": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/fn.name/-/fn.name-1.1.0.tgz", - "integrity": "sha512-GRnmB5gPyJpAhTQdSZTSp9uaPSvl09KoYcMQtsB9rQoOmzs9dH6ffeccH+Z+cv6P68Hu5bC6JjRh4Ah/mHSNRw==", - "license": "MIT" - }, - "node_modules/follow-redirects": { - "version": "1.15.11", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.11.tgz", - "integrity": "sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ==", - "funding": [ - { - "type": "individual", - "url": "https://github.com/sponsors/RubenVerborgh" - } - ], - "license": "MIT", - "engines": { - "node": ">=4.0" - }, - "peerDependenciesMeta": { - "debug": { - "optional": true - } - } - }, - "node_modules/form-data": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.5.tgz", - "integrity": "sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w==", - "license": "MIT", - "dependencies": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "es-set-tostringtag": "^2.1.0", - "hasown": "^2.0.2", - "mime-types": "^2.1.12" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/forwarded": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", - "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/fresh": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", - "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/fsevents": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", - "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", - "hasInstallScript": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^8.16.0 || ^10.6.0 || >=11.0.0" - } - }, - "node_modules/function-bind": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", - "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/get-intrinsic": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", - "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", - "license": "MIT", - "dependencies": { - "call-bind-apply-helpers": "^1.0.2", - "es-define-property": "^1.0.1", - "es-errors": "^1.3.0", - "es-object-atoms": "^1.1.1", - "function-bind": "^1.1.2", - "get-proto": "^1.0.1", - "gopd": "^1.2.0", - "has-symbols": "^1.1.0", - "hasown": "^2.0.2", - "math-intrinsics": "^1.1.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/get-proto": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", - "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", - "license": "MIT", - "dependencies": { - "dunder-proto": "^1.0.1", - "es-object-atoms": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/glob-parent": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", - "dev": true, - "license": "ISC", - "dependencies": { - "is-glob": "^4.0.1" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/gopd": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", - "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=4" - } - }, - "node_modules/has-symbols": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", - "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/has-tostringtag": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", - "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", - "license": "MIT", - "dependencies": { - "has-symbols": "^1.0.3" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/hasown": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", - "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", - "license": "MIT", - "dependencies": { - "function-bind": "^1.1.2" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/http-errors": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz", - "integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==", - "license": "MIT", - "dependencies": { - "depd": "~2.0.0", - "inherits": "~2.0.4", - "setprototypeof": "~1.2.0", - "statuses": "~2.0.2", - "toidentifier": "~1.0.1" - }, - "engines": { - "node": ">= 0.8" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/express" - } - }, - "node_modules/iconv-lite": { - "version": "0.4.24", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", - "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", - "license": "MIT", - "dependencies": { - "safer-buffer": ">= 2.1.2 < 3" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/ignore-by-default": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", - "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==", - "dev": true, - "license": "ISC" - }, - "node_modules/inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "license": "ISC" - }, - "node_modules/ip-address": { - "version": "10.0.1", - "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.0.1.tgz", - "integrity": "sha512-NWv9YLW4PoW2B7xtzaS3NCot75m6nK7Icdv0o3lfMceJVRfSoQwqD4wEH5rLwoKJwUiZ/rfpiVBhnaF0FK4HoA==", - "engines": { - "node": ">= 12" - } - }, - "node_modules/ipaddr.js": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", - "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", - "license": "MIT", - "engines": { - "node": ">= 0.10" - } - }, - "node_modules/is-binary-path": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", - "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", - "dev": true, - "license": "MIT", - "dependencies": { - "binary-extensions": "^2.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/is-extglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-glob": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", - "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", - "dev": true, - "license": "MIT", - "dependencies": { - "is-extglob": "^2.1.1" - }, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/is-number": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.12.0" - } - }, - "node_modules/is-stream": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", - "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", - "license": "MIT", - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/jsonwebtoken": { - "version": "9.0.3", - "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.3.tgz", - "integrity": "sha512-MT/xP0CrubFRNLNKvxJ2BYfy53Zkm++5bX9dtuPbqAeQpTVe0MQTFhao8+Cp//EmJp244xt6Drw/GVEGCUj40g==", - "license": "MIT", - "dependencies": { - "jws": "^4.0.1", - "lodash.includes": "^4.3.0", - "lodash.isboolean": "^3.0.3", - "lodash.isinteger": "^4.0.4", - "lodash.isnumber": "^3.0.3", - "lodash.isplainobject": "^4.0.6", - "lodash.isstring": "^4.0.1", - "lodash.once": "^4.0.0", - "ms": "^2.1.1", - "semver": "^7.5.4" - }, - "engines": { - "node": ">=12", - "npm": ">=6" - } - }, - "node_modules/jsonwebtoken/node_modules/ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "license": "MIT" - }, - "node_modules/jwa": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/jwa/-/jwa-2.0.1.tgz", - "integrity": "sha512-hRF04fqJIP8Abbkq5NKGN0Bbr3JxlQ+qhZufXVr0DvujKy93ZCbXZMHDL4EOtodSbCWxOqR8MS1tXA5hwqCXDg==", - "license": "MIT", - "dependencies": { - "buffer-equal-constant-time": "^1.0.1", - "ecdsa-sig-formatter": "1.0.11", - "safe-buffer": "^5.0.1" - } - }, - "node_modules/jws": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/jws/-/jws-4.0.1.tgz", - "integrity": "sha512-EKI/M/yqPncGUUh44xz0PxSidXFr/+r0pA70+gIYhjv+et7yxM+s29Y+VGDkovRofQem0fs7Uvf4+YmAdyRduA==", - "license": "MIT", - "dependencies": { - "jwa": "^2.0.1", - "safe-buffer": "^5.0.1" - } - }, - "node_modules/kuler": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/kuler/-/kuler-2.0.0.tgz", - "integrity": "sha512-Xq9nH7KlWZmXAtodXDDRE7vs6DU1gTU8zYDHDiWLSip45Egwq3plLHzPn27NgvzL2r1LMPC1vdqh98sQxtqj4A==", - "license": "MIT" - }, - "node_modules/lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", - "license": "MIT" - }, - "node_modules/lodash.includes": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", - "integrity": "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w==", - "license": "MIT" - }, - "node_modules/lodash.isboolean": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz", - "integrity": "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg==", - "license": "MIT" - }, - "node_modules/lodash.isinteger": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz", - "integrity": "sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA==", - "license": "MIT" - }, - "node_modules/lodash.isnumber": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz", - "integrity": "sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw==", - "license": "MIT" - }, - "node_modules/lodash.isplainobject": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", - "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==", - "license": "MIT" - }, - "node_modules/lodash.isstring": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", - "integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==", - "license": "MIT" - }, - "node_modules/lodash.once": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", - "integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==", - "license": "MIT" - }, - "node_modules/logform": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/logform/-/logform-2.7.0.tgz", - "integrity": "sha512-TFYA4jnP7PVbmlBIfhlSe+WKxs9dklXMTEGcBCIvLhE/Tn3H6Gk1norupVW7m5Cnd4bLcr08AytbyV/xj7f/kQ==", - "license": "MIT", - "dependencies": { - "@colors/colors": "1.6.0", - "@types/triple-beam": "^1.3.2", - "fecha": "^4.2.0", - "ms": "^2.1.1", - "safe-stable-stringify": "^2.3.1", - "triple-beam": "^1.3.0" - }, - "engines": { - "node": ">= 12.0.0" - } - }, - "node_modules/logform/node_modules/ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "license": "MIT" - }, - "node_modules/math-intrinsics": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", - "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/media-typer": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", - "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/merge-descriptors": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz", - "integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/methods": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", - "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/mime": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", - "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", - "license": "MIT", - "bin": { - "mime": "cli.js" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/mime-db": { - "version": "1.52.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", - "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/mime-types": { - "version": "2.1.35", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", - "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", - "license": "MIT", - "dependencies": { - "mime-db": "1.52.0" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", - "dev": true, - "license": "ISC", - "dependencies": { - "brace-expansion": "^1.1.7" - }, - "engines": { - "node": "*" - } - }, - "node_modules/ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", - "license": "MIT" - }, - "node_modules/negotiator": { - "version": "0.6.3", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", - "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/node-cron": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/node-cron/-/node-cron-3.0.3.tgz", - "integrity": "sha512-dOal67//nohNgYWb+nWmg5dkFdIwDm8EpeGYMekPMrngV3637lqnX0lbUcCtgibHTz6SEz7DAIjKvKDFYCnO1A==", - "license": "ISC", - "dependencies": { - "uuid": "8.3.2" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/nodemailer": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-8.0.1.tgz", - "integrity": "sha512-5kcldIXmaEjZcHR6F28IKGSgpmZHaF1IXLWFTG+Xh3S+Cce4MiakLtWY+PlBU69fLbRa8HlaGIrC/QolUpHkhg==", - "license": "MIT-0", - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/nodemon": { - "version": "3.1.11", - "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.11.tgz", - "integrity": "sha512-is96t8F/1//UHAjNPHpbsNY46ELPpftGUoSVNXwUfMk/qdjSylYrWSu1XavVTBOn526kFiOR733ATgNBCQyH0g==", - "dev": true, - "license": "MIT", - "dependencies": { - "chokidar": "^3.5.2", - "debug": "^4", - "ignore-by-default": "^1.0.1", - "minimatch": "^3.1.2", - "pstree.remy": "^1.1.8", - "semver": "^7.5.3", - "simple-update-notifier": "^2.0.0", - "supports-color": "^5.5.0", - "touch": "^3.1.0", - "undefsafe": "^2.0.5" - }, - "bin": { - "nodemon": "bin/nodemon.js" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/nodemon" - } - }, - "node_modules/nodemon/node_modules/debug": { - "version": "4.4.3", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", - "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", - "dev": true, - "license": "MIT", - "dependencies": { - "ms": "^2.1.3" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/nodemon/node_modules/ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "dev": true, - "license": "MIT" - }, - "node_modules/normalize-path": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/object-inspect": { - "version": "1.13.4", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", - "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/on-finished": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", - "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", - "license": "MIT", - "dependencies": { - "ee-first": "1.1.1" - }, - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/one-time": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/one-time/-/one-time-1.0.0.tgz", - "integrity": "sha512-5DXOiRKwuSEcQ/l0kGCF6Q3jcADFv5tSmRaJck/OqkVFcOzutB134KRSfF0xDrL39MNnqxbHBbUUcjZIhTgb2g==", - "license": "MIT", - "dependencies": { - "fn.name": "1.x.x" - } - }, - "node_modules/parseurl": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", - "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/path-to-regexp": { - "version": "0.1.12", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz", - "integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==", - "license": "MIT" - }, - "node_modules/picomatch": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", - "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=8.6" - }, - "funding": { - "url": "https://github.com/sponsors/jonschlinkert" - } - }, - "node_modules/prisma": { - "version": "5.22.0", - "resolved": "https://registry.npmjs.org/prisma/-/prisma-5.22.0.tgz", - "integrity": "sha512-vtpjW3XuYCSnMsNVBjLMNkTj6OZbudcPPTPYHqX0CJfpcdWciI1dM8uHETwmDxxiqEwCIE6WvXucWUetJgfu/A==", - "hasInstallScript": true, - "dependencies": { - "@prisma/engines": "5.22.0" - }, - "bin": { - "prisma": "build/index.js" - }, - "engines": { - "node": ">=16.13" - }, - "optionalDependencies": { - "fsevents": "2.3.3" - } - }, - "node_modules/proxy-addr": { - "version": "2.0.7", - "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", - "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", - "license": "MIT", - "dependencies": { - "forwarded": "0.2.0", - "ipaddr.js": "1.9.1" - }, - "engines": { - "node": ">= 0.10" - } - }, - "node_modules/proxy-from-env": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", - "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", - "license": "MIT" - }, - "node_modules/pstree.remy": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", - "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==", - "dev": true, - "license": "MIT" - }, - "node_modules/qs": { - "version": "6.14.1", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.14.1.tgz", - "integrity": "sha512-4EK3+xJl8Ts67nLYNwqw/dsFVnCf+qR7RgXSK9jEEm9unao3njwMDdmsdvoKBKHzxd7tCYz5e5M+SnMjdtXGQQ==", - "license": "BSD-3-Clause", - "dependencies": { - "side-channel": "^1.1.0" - }, - "engines": { - "node": ">=0.6" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/range-parser": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", - "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/raw-body": { - "version": "2.5.3", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.3.tgz", - "integrity": "sha512-s4VSOf6yN0rvbRZGxs8Om5CWj6seneMwK3oDb4lWDH0UPhWcxwOWw5+qk24bxq87szX1ydrwylIOp2uG1ojUpA==", - "license": "MIT", - "dependencies": { - "bytes": "~3.1.2", - "http-errors": "~2.0.1", - "iconv-lite": "~0.4.24", - "unpipe": "~1.0.0" - }, - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/readable-stream": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", - "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", - "license": "MIT", - "dependencies": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/readdirp": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", - "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", - "dev": true, - "license": "MIT", - "dependencies": { - "picomatch": "^2.2.1" - }, - "engines": { - "node": ">=8.10.0" - } - }, - "node_modules/safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT" - }, - "node_modules/safe-stable-stringify": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/safe-stable-stringify/-/safe-stable-stringify-2.5.0.tgz", - "integrity": "sha512-b3rppTKm9T+PsVCBEOUR46GWI7fdOs00VKZ1+9c1EWDaDMvjQc6tUwuFyIprgGgTcWoVHSKrU8H31ZHA2e0RHA==", - "license": "MIT", - "engines": { - "node": ">=10" - } - }, - "node_modules/safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", - "license": "MIT" - }, - "node_modules/semver": { - "version": "7.7.3", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.3.tgz", - "integrity": "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q==", - "license": "ISC", - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/send": { - "version": "0.19.2", - "resolved": "https://registry.npmjs.org/send/-/send-0.19.2.tgz", - "integrity": "sha512-VMbMxbDeehAxpOtWJXlcUS5E8iXh6QmN+BkRX1GARS3wRaXEEgzCcB10gTQazO42tpNIya8xIyNx8fll1OFPrg==", - "license": "MIT", - "dependencies": { - "debug": "2.6.9", - "depd": "2.0.0", - "destroy": "1.2.0", - "encodeurl": "~2.0.0", - "escape-html": "~1.0.3", - "etag": "~1.8.1", - "fresh": "~0.5.2", - "http-errors": "~2.0.1", - "mime": "1.6.0", - "ms": "2.1.3", - "on-finished": "~2.4.1", - "range-parser": "~1.2.1", - "statuses": "~2.0.2" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/send/node_modules/ms": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "license": "MIT" - }, - "node_modules/serve-static": { - "version": "1.16.3", - "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.3.tgz", - "integrity": "sha512-x0RTqQel6g5SY7Lg6ZreMmsOzncHFU7nhnRWkKgWuMTu5NN0DR5oruckMqRvacAN9d5w6ARnRBXl9xhDCgfMeA==", - "license": "MIT", - "dependencies": { - "encodeurl": "~2.0.0", - "escape-html": "~1.0.3", - "parseurl": "~1.3.3", - "send": "~0.19.1" - }, - "engines": { - "node": ">= 0.8.0" - } - }, - "node_modules/setprototypeof": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", - "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", - "license": "ISC" - }, - "node_modules/side-channel": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", - "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==", - "license": "MIT", - "dependencies": { - "es-errors": "^1.3.0", - "object-inspect": "^1.13.3", - "side-channel-list": "^1.0.0", - "side-channel-map": "^1.0.1", - "side-channel-weakmap": "^1.0.2" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/side-channel-list": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz", - "integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==", - "license": "MIT", - "dependencies": { - "es-errors": "^1.3.0", - "object-inspect": "^1.13.3" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/side-channel-map": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", - "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", - "license": "MIT", - "dependencies": { - "call-bound": "^1.0.2", - "es-errors": "^1.3.0", - "get-intrinsic": "^1.2.5", - "object-inspect": "^1.13.3" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/side-channel-weakmap": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", - "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", - "license": "MIT", - "dependencies": { - "call-bound": "^1.0.2", - "es-errors": "^1.3.0", - "get-intrinsic": "^1.2.5", - "object-inspect": "^1.13.3", - "side-channel-map": "^1.0.1" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/simple-update-notifier": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz", - "integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==", - "dev": true, - "license": "MIT", - "dependencies": { - "semver": "^7.5.3" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/stack-trace": { - "version": "0.0.10", - "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz", - "integrity": "sha512-KGzahc7puUKkzyMt+IqAep+TVNbKP+k2Lmwhub39m1AsTSkaDutx56aDCo+HLDzf/D26BIHTJWNiTG1KAJiQCg==", - "license": "MIT", - "engines": { - "node": "*" - } - }, - "node_modules/statuses": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", - "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/string_decoder": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", - "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", - "license": "MIT", - "dependencies": { - "safe-buffer": "~5.2.0" - } - }, - "node_modules/supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", - "dev": true, - "license": "MIT", - "dependencies": { - "has-flag": "^3.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/text-hex": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/text-hex/-/text-hex-1.0.0.tgz", - "integrity": "sha512-uuVGNWzgJ4yhRaNSiubPY7OjISw4sw4E5Uv0wbjp+OzcbmVU/rsT8ujgcXJhn9ypzsgr5vlzpPqP+MBBKcGvbg==", - "license": "MIT" - }, - "node_modules/to-regex-range": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", - "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "is-number": "^7.0.0" - }, - "engines": { - "node": ">=8.0" - } - }, - "node_modules/toidentifier": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", - "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", - "license": "MIT", - "engines": { - "node": ">=0.6" - } - }, - "node_modules/touch": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.1.tgz", - "integrity": "sha512-r0eojU4bI8MnHr8c5bNo7lJDdI2qXlWWJk6a9EAFG7vbhTjElYhBVS3/miuE0uOuoLdb8Mc/rVfsmm6eo5o9GA==", - "dev": true, - "license": "ISC", - "bin": { - "nodetouch": "bin/nodetouch.js" - } - }, - "node_modules/triple-beam": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/triple-beam/-/triple-beam-1.4.1.tgz", - "integrity": "sha512-aZbgViZrg1QNcG+LULa7nhZpJTZSLm/mXnHXnbAbjmN5aSa0y7V+wvv6+4WaBtpISJzThKy+PIPxc1Nq1EJ9mg==", - "license": "MIT", - "engines": { - "node": ">= 14.0.0" - } - }, - "node_modules/type-is": { - "version": "1.6.18", - "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", - "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", - "license": "MIT", - "dependencies": { - "media-typer": "0.3.0", - "mime-types": "~2.1.24" - }, - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/undefsafe": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz", - "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==", - "dev": true, - "license": "MIT" - }, - "node_modules/unpipe": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", - "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", - "license": "MIT" - }, - "node_modules/utils-merge": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", - "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==", - "license": "MIT", - "engines": { - "node": ">= 0.4.0" - } - }, - "node_modules/uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", - "license": "MIT", - "bin": { - "uuid": "dist/bin/uuid" - } - }, - "node_modules/validator": { - "version": "13.15.26", - "resolved": "https://registry.npmjs.org/validator/-/validator-13.15.26.tgz", - "integrity": "sha512-spH26xU080ydGggxRyR1Yhcbgx+j3y5jbNXk/8L+iRvdIEQ4uTRH2Sgf2dokud6Q4oAtsbNvJ1Ft+9xmm6IZcA==", - "license": "MIT", - "engines": { - "node": ">= 0.10" - } - }, - "node_modules/vary": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", - "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", - "license": "MIT", - "engines": { - "node": ">= 0.8" - } - }, - "node_modules/winston": { - "version": "3.19.0", - "resolved": "https://registry.npmjs.org/winston/-/winston-3.19.0.tgz", - "integrity": "sha512-LZNJgPzfKR+/J3cHkxcpHKpKKvGfDZVPS4hfJCc4cCG0CgYzvlD6yE/S3CIL/Yt91ak327YCpiF/0MyeZHEHKA==", - "license": "MIT", - "dependencies": { - "@colors/colors": "^1.6.0", - "@dabh/diagnostics": "^2.0.8", - "async": "^3.2.3", - "is-stream": "^2.0.0", - "logform": "^2.7.0", - "one-time": "^1.0.0", - "readable-stream": "^3.4.0", - "safe-stable-stringify": "^2.3.1", - "stack-trace": "0.0.x", - "triple-beam": "^1.3.0", - "winston-transport": "^4.9.0" - }, - "engines": { - "node": ">= 12.0.0" - } - }, - "node_modules/winston-transport": { - "version": "4.9.0", - "resolved": "https://registry.npmjs.org/winston-transport/-/winston-transport-4.9.0.tgz", - "integrity": "sha512-8drMJ4rkgaPo1Me4zD/3WLfI/zPdA9o2IipKODunnGDcuqbHwjsbB79ylv04LCGGzU0xQ6vTznOMpQGaLhhm6A==", - "license": "MIT", - "dependencies": { - "logform": "^2.7.0", - "readable-stream": "^3.6.2", - "triple-beam": "^1.3.0" - }, - "engines": { - "node": ">= 12.0.0" - } - } - } -}