fix(gateway): implement proxy routes and schemas for Study Hub features#570
Conversation
|
@Sandeep6135 is attempting to deploy a commit to the firefistisdead's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Warning Review limit reached
More reviews will be available in 47 minutes and 39 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Pull request overview
This PR fixes missing API Gateway (Express) proxy routes for the “Study Hub” frontend features by adding three new POST endpoints that validate request bodies and forward calls to the Python RAG service using the correct upstream paths.
Changes:
- Added
/knowledge-gapsproxy route with request validation viaknowledgeGapsSchema. - Added
/sessions/flashcardsproxy route that maps to the upstream/sessions/flashcards/generateendpoint and validates viagenerateFlashcardsSchema. - Added
/sessions/flashcards/progressproxy route that maps to the upstream/sessions/flashcards/update-progressendpoint and validates viaupdateFlashcardProgressSchema.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| app.post("/knowledge-gaps", inferenceSlowDown, inferenceLimiter, async (req, res) => { | ||
| const resolvedSessionSecret = await resolveSessionSecret( | ||
| req, | ||
| req.body?.session_id, |
Pull Request: Resolve API Gateway Proxy Omission & Mismatch for Study Hub Features
Closes #563
📌 Classification & Priority
bug-fixcriticalapi-gatewayexceptional-proxy-resolution📖 Summary
Important
This PR resolves a critical system integration failure where Study Hub features (Knowledge Gaps, Flashcard Generation, and Flashcard Progress updates) were completely non-functional in production due to a missing proxy layer in the Node.js API Gateway (
server.js) and mismatched endpoint naming conventions.🔴 Problem
The React frontend attempts to call
/knowledge-gaps,/sessions/flashcards, and/sessions/flashcards/progresson the API Gateway. However,server.jslacked definitions, rate limits, slow-down configs, and validation schemas for these routes, causing all requests to fail with404 Route not found. In addition, if the requests were passed through directly, they would fail at the backend because the Python service expects/sessions/flashcards/generateand/sessions/flashcards/update-progressrespectively.🟢 Solution
Exposed and defined the three proxy endpoints inside
server.jswith correct mapping logic:generateFlashcardsSchemaandupdateFlashcardProgressSchemafrom./validators/schemasto perform structural validation./knowledge-gapsproxy route mapping to the Python RAG service's/knowledge-gapsendpoint./sessions/flashcardsproxy route mapping to the Python RAG service's/sessions/flashcards/generateendpoint./sessions/flashcards/progressproxy route mapping to the Python RAG service's/sessions/flashcards/update-progressendpoint.inferenceLimiter) and request slowing handlers (inferenceSlowDown) to protect the new endpoints against brute force and resource exhaustion.🧪 Steps to Reproduce
🔍 Expected Behaviour
All Study Hub UI actions (flashcard generation, study progression rating, and prerequisite concept mapping) execute successfully and fetch context-relevant details from the backend without 404 errors.
❌ Actual Behaviour (Before Fix)
The Express server rejected all incoming Study Hub requests with 404 Route Not Found, rendering the features entirely broken.
🛠️ Code Diff Walkthrough
server.js