Skip to content

Event serach by slug#87

Merged
djdiptayan1 merged 4 commits intoreleasefrom
staging
Nov 7, 2025
Merged

Event serach by slug#87
djdiptayan1 merged 4 commits intoreleasefrom
staging

Conversation

@djdiptayan1
Copy link
Copy Markdown
Member

OS

Copilot AI review requested due to automatic review settings November 7, 2025 21:18
@vercel
Copy link
Copy Markdown

vercel bot commented Nov 7, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
gcsrm-server Ready Ready Preview Comment Nov 7, 2025 9:18pm

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Nov 7, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch staging

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@djdiptayan1 djdiptayan1 merged commit 16fdc84 into release Nov 7, 2025
10 checks passed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new endpoint to fetch events by slug identifier instead of MongoDB ObjectId, providing a more user-friendly way to access event data via URL-friendly slugs. The version has been bumped to 1.1.0 to reflect this new feature.

  • Added fetchEventSlug controller function to retrieve events using slug identifiers
  • Added /events/slug/:slug route with Swagger documentation
  • Version bump from 1.0.0 to 1.1.0

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/controller/event.controller.js Implements fetchEventSlug function with slug-based event lookup, error handling, and Sentry logging
src/routes/event.route.js Adds new route /slug/:slug with comprehensive Swagger documentation and imports fetchEventSlug controller
package.json Version bump to 1.1.0 reflecting the new feature

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +179 to +181
// Use case-insensitive regex to match slugs regardless of case
const fetchedEvent = await eventSchema.findOne({
slug: { $regex: new RegExp(`^${normalizedSlug}$`, 'i') }
Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Security and performance issue: The slug parameter is directly interpolated into a regex pattern without escaping special regex characters, creating a ReDoS (Regular Expression Denial of Service) vulnerability. An attacker could provide input like (a+)+$ to cause catastrophic backtracking.

Additionally, since the slug field in the schema is defined with lowercase: true (meaning all slugs are stored in lowercase), the case-insensitive regex is unnecessary and inefficient.

Replace with a simple, safe equality match:

const fetchedEvent = await eventSchema.findOne({
    slug: normalizedSlug.toLowerCase()
}).lean();

This is faster, avoids regex overhead, and eliminates the security vulnerability.

Suggested change
// Use case-insensitive regex to match slugs regardless of case
const fetchedEvent = await eventSchema.findOne({
slug: { $regex: new RegExp(`^${normalizedSlug}$`, 'i') }
// Use direct equality match for slug (stored in lowercase)
const fetchedEvent = await eventSchema.findOne({
slug: normalizedSlug.toLowerCase()

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants