Skip to content

refactor: flatten auth json proxy imports#412

Merged
jerry609 merged 1 commit intodevfrom
refactor/pr17-auth-proxy-import-flatten
Mar 15, 2026
Merged

refactor: flatten auth json proxy imports#412
jerry609 merged 1 commit intodevfrom
refactor/pr17-auth-proxy-import-flatten

Conversation

@jerry609
Copy link
Owner

Summary

  • add a shared auth-json-proxy helper under web/src/app/api/_utils
  • repoint every auth-protected JSON route that still imported research/_base to the shared helper path
  • delete the legacy research/_base shim and move its focused contract test alongside the new helper

Why

The old research/_base name had become misleading because it was used across research, model-endpoints, embedding-settings, newsletter, and papers routes. This PR flattens those imports into a generic utility location so the remaining API proxy surface matches the actual module boundaries.

Validation

  • cd web && npx vitest run src/app/api/_utils/auth-json-proxy.test.ts src/app/api/research/repro/context/route.test.ts src/app/api/_utils/backend-proxy.test.ts
  • cd web && npx eslint src/app/api/_utils/auth-json-proxy.ts src/app/api/_utils/auth-json-proxy.test.ts src/app/api/research/repro/context/route.test.ts
  • cd web && npx tsc --noEmit
  • cd web && npm run build

Copilot AI review requested due to automatic review settings March 15, 2026 08:05
@vercel
Copy link

vercel bot commented Mar 15, 2026

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

Project Deployment Actions Updated (UTC)
paper-bot Ready Ready Preview, Comment Mar 15, 2026 8:06am

@coderabbitai
Copy link

coderabbitai bot commented Mar 15, 2026

Warning

Rate limit exceeded

@jerry609 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 6 minutes and 6 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 98f6a9b0-0252-4ec5-a38a-a423dc1e9d3e

📥 Commits

Reviewing files that changed from the base of the PR and between d6023d1 and e6af89c.

📒 Files selected for processing (63)
  • web/src/app/api/_utils/auth-json-proxy.test.ts
  • web/src/app/api/_utils/auth-json-proxy.ts
  • web/src/app/api/embedding-settings/route.ts
  • web/src/app/api/embedding-settings/test/route.ts
  • web/src/app/api/model-endpoints/[id]/activate/route.ts
  • web/src/app/api/model-endpoints/[id]/route.ts
  • web/src/app/api/model-endpoints/[id]/test/route.ts
  • web/src/app/api/model-endpoints/route.ts
  • web/src/app/api/model-endpoints/usage/route.ts
  • web/src/app/api/newsletter/subscribe/route.ts
  • web/src/app/api/newsletter/subscribers/route.ts
  • web/src/app/api/papers/[paperId]/save/route.ts
  • web/src/app/api/papers/library/route.ts
  • web/src/app/api/research/_base.ts
  • web/src/app/api/research/collections/[collectionId]/items/[paperId]/route.ts
  • web/src/app/api/research/collections/[collectionId]/items/route.ts
  • web/src/app/api/research/collections/[collectionId]/route.ts
  • web/src/app/api/research/collections/route.ts
  • web/src/app/api/research/context/route.ts
  • web/src/app/api/research/deadlines/radar/route.ts
  • web/src/app/api/research/discovery/seed/route.ts
  • web/src/app/api/research/evals/summary/route.ts
  • web/src/app/api/research/integrations/zotero/pull/route.ts
  • web/src/app/api/research/integrations/zotero/push/route.ts
  • web/src/app/api/research/memory/bulk_moderate/route.ts
  • web/src/app/api/research/memory/bulk_move/route.ts
  • web/src/app/api/research/memory/inbox/route.ts
  • web/src/app/api/research/memory/items/[itemId]/moderate/route.ts
  • web/src/app/api/research/memory/suggest/route.ts
  • web/src/app/api/research/papers/[paperId]/card/route.ts
  • web/src/app/api/research/papers/[paperId]/route.ts
  • web/src/app/api/research/papers/[paperId]/status/route.ts
  • web/src/app/api/research/papers/feedback/route.ts
  • web/src/app/api/research/papers/import/bibtex/route.ts
  • web/src/app/api/research/papers/related-work/route.ts
  • web/src/app/api/research/papers/saved/route.ts
  • web/src/app/api/research/paperscool/approvals/route.ts
  • web/src/app/api/research/paperscool/repos/route.ts
  • web/src/app/api/research/paperscool/search/route.ts
  • web/src/app/api/research/paperscool/sessions/[sessionId]/approve/route.ts
  • web/src/app/api/research/paperscool/sessions/[sessionId]/reject/route.ts
  • web/src/app/api/research/repro/context/[packId]/observation/[observationId]/route.ts
  • web/src/app/api/research/repro/context/[packId]/route.ts
  • web/src/app/api/research/repro/context/[packId]/session/route.ts
  • web/src/app/api/research/repro/context/route.test.ts
  • web/src/app/api/research/repro/context/route.ts
  • web/src/app/api/research/router/suggest/route.ts
  • web/src/app/api/research/scholar/network/route.ts
  • web/src/app/api/research/scholar/trends/route.ts
  • web/src/app/api/research/scholars/[scholarRef]/route.ts
  • web/src/app/api/research/scholars/route.ts
  • web/src/app/api/research/scholars/search/route.ts
  • web/src/app/api/research/tracks/[trackId]/activate/route.ts
  • web/src/app/api/research/tracks/[trackId]/anchors/[authorId]/action/route.ts
  • web/src/app/api/research/tracks/[trackId]/anchors/actions/route.ts
  • web/src/app/api/research/tracks/[trackId]/anchors/discover/route.ts
  • web/src/app/api/research/tracks/[trackId]/context/route.ts
  • web/src/app/api/research/tracks/[trackId]/feed/route.ts
  • web/src/app/api/research/tracks/[trackId]/memory/clear/route.ts
  • web/src/app/api/research/tracks/[trackId]/route.ts
  • web/src/app/api/research/tracks/[trackId]/tasks/route.ts
  • web/src/app/api/research/tracks/active/route.ts
  • web/src/app/api/research/tracks/route.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/pr17-auth-proxy-import-flatten
📝 Coding Plan
  • Generate coding plan for human review comments

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.

@sonarqubecloud
Copy link

@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refactors the application's API proxy infrastructure by consolidating authentication-related JSON proxy logic into a single, dedicated utility. This change addresses the misleading naming and broad usage of the former research/_base module, improving code organization, clarity, and maintainability across various API routes.

Highlights

  • Centralized Auth Proxy: A new shared auth-json-proxy helper was introduced under web/src/app/api/_utils to centralize authentication proxy logic.
  • Import Path Refactoring: All API routes that previously imported the research/_base utility were updated to use the new shared auth-json-proxy helper, ensuring consistent and correct module boundaries.
  • Legacy Code Removal: The deprecated research/_base shim was removed, and its associated contract test was relocated to reside alongside the new auth-json-proxy helper.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • web/src/app/api/_utils/auth-json-proxy.ts
    • Added a new utility file that exports apiBaseUrl and a proxyJson function, which wraps the shared backend-proxy with authentication enabled.
  • web/src/app/api/embedding-settings/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/embedding-settings/test/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/model-endpoints/[id]/activate/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/model-endpoints/[id]/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/model-endpoints/[id]/test/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/model-endpoints/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/model-endpoints/usage/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/newsletter/subscribe/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/newsletter/subscribers/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/papers/[paperId]/save/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/papers/library/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/_base.test.ts
    • Renamed to web/src/app/api/_utils/auth-json-proxy.test.ts.
    • Updated mock import path to reflect the new utility location.
    • Updated the test suite description to 'auth json proxy'.
  • web/src/app/api/research/_base.ts
    • Removed the deprecated _base utility file.
  • web/src/app/api/research/collections/[collectionId]/items/[paperId]/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/collections/[collectionId]/items/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/collections/[collectionId]/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/collections/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/context/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/deadlines/radar/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/discovery/seed/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/evals/summary/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/integrations/zotero/pull/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/integrations/zotero/push/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/memory/bulk_moderate/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/memory/bulk_move/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/memory/inbox/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/memory/items/[itemId]/moderate/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/memory/suggest/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/papers/[paperId]/card/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/papers/[paperId]/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/papers/[paperId]/status/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/papers/feedback/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/papers/import/bibtex/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/papers/related-work/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/papers/saved/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/paperscool/approvals/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/paperscool/repos/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/paperscool/search/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/paperscool/sessions/[sessionId]/approve/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/paperscool/sessions/[sessionId]/reject/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/repro/context/[packId]/observation/[observationId]/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/repro/context/[packId]/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/repro/context/[packId]/session/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/repro/context/route.test.ts
    • Updated the mock import path for auth-json-proxy.
  • web/src/app/api/research/repro/context/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/router/suggest/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/scholar/network/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/scholar/trends/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/scholars/[scholarRef]/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/scholars/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/scholars/search/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/tracks/[trackId]/activate/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/tracks/[trackId]/anchors/[authorId]/action/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/tracks/[trackId]/anchors/actions/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/tracks/[trackId]/anchors/discover/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/tracks/[trackId]/context/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/tracks/[trackId]/feed/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/tracks/[trackId]/memory/clear/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/tracks/[trackId]/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/tracks/[trackId]/tasks/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/tracks/active/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
  • web/src/app/api/research/tracks/route.ts
    • Updated the import path for apiBaseUrl and proxyJson to the new shared auth-json-proxy.
Activity
  • No specific activity (comments, reviews, progress) has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

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 consolidates the research/_base auth proxy shim into a shared _utils/auth-json-proxy module, since it was being imported by routes outside the research/ directory (e.g., model-endpoints, embedding-settings, newsletter, papers). The legacy shim is deleted and all imports are repointed.

Changes:

  • Added web/src/app/api/_utils/auth-json-proxy.ts as a shared utility exporting apiBaseUrl and an auth-enabled proxyJson wrapper.
  • Updated ~50 route files to import from the new @/app/api/_utils/auth-json-proxy path instead of research/_base.
  • Deleted the legacy research/_base.ts shim and relocated its test.

Reviewed changes

Copilot reviewed 63 out of 63 changed files in this pull request and generated no comments.

Show a summary per file
File Description
web/src/app/api/_utils/auth-json-proxy.ts New shared auth JSON proxy helper (replaces research/_base.ts)
web/src/app/api/_utils/auth-json-proxy.test.ts Updated test: mock path and import corrected to match new location
web/src/app/api/research/_base.ts Deleted legacy shim
~50 route.ts files Mechanical import path change to @/app/api/_utils/auth-json-proxy
web/src/app/api/research/repro/context/route.test.ts Updated vi.mock path to match new import

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

You can also share your feedback on Copilot code review. Take the survey.

@github-actions
Copy link

Vercel Preview

@jerry609 jerry609 merged commit dc20b30 into dev Mar 15, 2026
20 checks passed
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the authentication-protected JSON proxy helpers into a shared utility auth-json-proxy under web/src/app/api/_utils. This is a great improvement for code organization and maintainability, as it centralizes the logic and replaces many confusing relative imports with a clear, absolute path. The changes are extensive but consistent across the codebase. I've added one suggestion to the new auth-json-proxy.ts file to make the re-export syntax more explicit and concise.

Comment on lines +1 to +4
import { apiBaseUrl, proxyJson as sharedProxyJson } from "./backend-proxy"
import type { ProxyMethod } from "./backend-proxy"

export { apiBaseUrl }

Choose a reason for hiding this comment

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

medium

For better clarity and conciseness, you can use export ... from syntax to directly re-export apiBaseUrl. This makes it explicit that the module is simply passing it through. You can also combine the other imports from ./backend-proxy into a single statement.

Suggested change
import { apiBaseUrl, proxyJson as sharedProxyJson } from "./backend-proxy"
import type { ProxyMethod } from "./backend-proxy"
export { apiBaseUrl }
export { apiBaseUrl } from "./backend-proxy"
import { proxyJson as sharedProxyJson, type ProxyMethod } from "./backend-proxy"

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