From e6af89c19515970799bde0e4b51b6821576ba18c Mon Sep 17 00:00:00 2001 From: jerry609 <1772030600@qq.com> Date: Sun, 15 Mar 2026 16:04:44 +0800 Subject: [PATCH] refactor: flatten auth json proxy imports --- .../auth-json-proxy.test.ts} | 6 +++--- web/src/app/api/_utils/auth-json-proxy.ts | 12 ++++++++++++ web/src/app/api/embedding-settings/route.ts | 2 +- .../app/api/embedding-settings/test/route.ts | 2 +- .../api/model-endpoints/[id]/activate/route.ts | 2 +- web/src/app/api/model-endpoints/[id]/route.ts | 2 +- .../app/api/model-endpoints/[id]/test/route.ts | 2 +- web/src/app/api/model-endpoints/route.ts | 2 +- web/src/app/api/model-endpoints/usage/route.ts | 2 +- web/src/app/api/newsletter/subscribe/route.ts | 2 +- web/src/app/api/newsletter/subscribers/route.ts | 2 +- web/src/app/api/papers/[paperId]/save/route.ts | 2 +- web/src/app/api/papers/library/route.ts | 2 +- web/src/app/api/research/_base.ts | 17 ----------------- .../[collectionId]/items/[paperId]/route.ts | 2 +- .../collections/[collectionId]/items/route.ts | 2 +- .../collections/[collectionId]/route.ts | 2 +- web/src/app/api/research/collections/route.ts | 2 +- web/src/app/api/research/context/route.ts | 2 +- .../app/api/research/deadlines/radar/route.ts | 2 +- .../app/api/research/discovery/seed/route.ts | 2 +- web/src/app/api/research/evals/summary/route.ts | 2 +- .../research/integrations/zotero/pull/route.ts | 2 +- .../research/integrations/zotero/push/route.ts | 2 +- .../api/research/memory/bulk_moderate/route.ts | 2 +- .../app/api/research/memory/bulk_move/route.ts | 2 +- web/src/app/api/research/memory/inbox/route.ts | 2 +- .../memory/items/[itemId]/moderate/route.ts | 2 +- .../app/api/research/memory/suggest/route.ts | 2 +- .../api/research/papers/[paperId]/card/route.ts | 2 +- .../app/api/research/papers/[paperId]/route.ts | 2 +- .../research/papers/[paperId]/status/route.ts | 2 +- .../app/api/research/papers/feedback/route.ts | 2 +- .../api/research/papers/import/bibtex/route.ts | 2 +- .../api/research/papers/related-work/route.ts | 2 +- web/src/app/api/research/papers/saved/route.ts | 2 +- .../api/research/paperscool/approvals/route.ts | 2 +- .../app/api/research/paperscool/repos/route.ts | 2 +- .../app/api/research/paperscool/search/route.ts | 2 +- .../sessions/[sessionId]/approve/route.ts | 2 +- .../sessions/[sessionId]/reject/route.ts | 2 +- .../observation/[observationId]/route.ts | 2 +- .../research/repro/context/[packId]/route.ts | 2 +- .../repro/context/[packId]/session/route.ts | 2 +- .../api/research/repro/context/route.test.ts | 2 +- web/src/app/api/research/repro/context/route.ts | 2 +- .../app/api/research/router/suggest/route.ts | 2 +- .../app/api/research/scholar/network/route.ts | 2 +- .../app/api/research/scholar/trends/route.ts | 2 +- .../api/research/scholars/[scholarRef]/route.ts | 2 +- web/src/app/api/research/scholars/route.ts | 2 +- .../app/api/research/scholars/search/route.ts | 2 +- .../research/tracks/[trackId]/activate/route.ts | 2 +- .../anchors/[authorId]/action/route.ts | 2 +- .../tracks/[trackId]/anchors/actions/route.ts | 2 +- .../tracks/[trackId]/anchors/discover/route.ts | 2 +- .../research/tracks/[trackId]/context/route.ts | 2 +- .../api/research/tracks/[trackId]/feed/route.ts | 2 +- .../tracks/[trackId]/memory/clear/route.ts | 2 +- .../app/api/research/tracks/[trackId]/route.ts | 2 +- .../research/tracks/[trackId]/tasks/route.ts | 2 +- web/src/app/api/research/tracks/active/route.ts | 2 +- web/src/app/api/research/tracks/route.ts | 2 +- 63 files changed, 75 insertions(+), 80 deletions(-) rename web/src/app/api/{research/_base.test.ts => _utils/auth-json-proxy.test.ts} (89%) create mode 100644 web/src/app/api/_utils/auth-json-proxy.ts delete mode 100644 web/src/app/api/research/_base.ts diff --git a/web/src/app/api/research/_base.test.ts b/web/src/app/api/_utils/auth-json-proxy.test.ts similarity index 89% rename from web/src/app/api/research/_base.test.ts rename to web/src/app/api/_utils/auth-json-proxy.test.ts index bdbe9e6f..907de6d5 100644 --- a/web/src/app/api/research/_base.test.ts +++ b/web/src/app/api/_utils/auth-json-proxy.test.ts @@ -5,14 +5,14 @@ const { sharedApiBaseUrlMock, sharedProxyJsonMock } = vi.hoisted(() => ({ sharedProxyJsonMock: vi.fn(), })) -vi.mock("../_utils/backend-proxy", () => ({ +vi.mock("./backend-proxy", () => ({ apiBaseUrl: sharedApiBaseUrlMock, proxyJson: sharedProxyJsonMock, })) -import { apiBaseUrl, proxyJson } from "./_base" +import { apiBaseUrl, proxyJson } from "./auth-json-proxy" -describe("research base proxy", () => { +describe("auth json proxy", () => { it("delegates backend base URL resolution to the shared helper", () => { expect(apiBaseUrl()).toBe("https://backend.test") expect(sharedApiBaseUrlMock).toHaveBeenCalledTimes(1) diff --git a/web/src/app/api/_utils/auth-json-proxy.ts b/web/src/app/api/_utils/auth-json-proxy.ts new file mode 100644 index 00000000..821710c1 --- /dev/null +++ b/web/src/app/api/_utils/auth-json-proxy.ts @@ -0,0 +1,12 @@ +import { apiBaseUrl, proxyJson as sharedProxyJson } from "./backend-proxy" +import type { ProxyMethod } from "./backend-proxy" + +export { apiBaseUrl } + +export function proxyJson( + req: Request, + upstreamUrl: string, + method: ProxyMethod, +): Promise { + return sharedProxyJson(req, upstreamUrl, method, { auth: true }) +} diff --git a/web/src/app/api/embedding-settings/route.ts b/web/src/app/api/embedding-settings/route.ts index 3d8c7d7b..d619a14e 100644 --- a/web/src/app/api/embedding-settings/route.ts +++ b/web/src/app/api/embedding-settings/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../research/_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function GET(req: Request) { return proxyJson(req, `${apiBaseUrl()}/api/embedding-settings`, "GET") diff --git a/web/src/app/api/embedding-settings/test/route.ts b/web/src/app/api/embedding-settings/test/route.ts index 615c8727..0b475fdd 100644 --- a/web/src/app/api/embedding-settings/test/route.ts +++ b/web/src/app/api/embedding-settings/test/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../../research/_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function POST(req: Request) { return proxyJson(req, `${apiBaseUrl()}/api/embedding-settings/test`, "POST") diff --git a/web/src/app/api/model-endpoints/[id]/activate/route.ts b/web/src/app/api/model-endpoints/[id]/activate/route.ts index 4c64a5d6..72b9a291 100644 --- a/web/src/app/api/model-endpoints/[id]/activate/route.ts +++ b/web/src/app/api/model-endpoints/[id]/activate/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../../../research/_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function POST(req: Request, ctx: { params: Promise<{ id: string }> }) { const { id } = await ctx.params diff --git a/web/src/app/api/model-endpoints/[id]/route.ts b/web/src/app/api/model-endpoints/[id]/route.ts index c4041d00..49a68fb3 100644 --- a/web/src/app/api/model-endpoints/[id]/route.ts +++ b/web/src/app/api/model-endpoints/[id]/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../../research/_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function PATCH(req: Request, ctx: { params: Promise<{ id: string }> }) { const { id } = await ctx.params diff --git a/web/src/app/api/model-endpoints/[id]/test/route.ts b/web/src/app/api/model-endpoints/[id]/test/route.ts index 20a02fdf..2c8b228d 100644 --- a/web/src/app/api/model-endpoints/[id]/test/route.ts +++ b/web/src/app/api/model-endpoints/[id]/test/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../../../research/_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function POST(req: Request, ctx: { params: Promise<{ id: string }> }) { const { id } = await ctx.params diff --git a/web/src/app/api/model-endpoints/route.ts b/web/src/app/api/model-endpoints/route.ts index b0b1bc06..53a0b18b 100644 --- a/web/src/app/api/model-endpoints/route.ts +++ b/web/src/app/api/model-endpoints/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../research/_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function GET(req: Request) { const url = new URL(req.url) diff --git a/web/src/app/api/model-endpoints/usage/route.ts b/web/src/app/api/model-endpoints/usage/route.ts index 1522edfc..c02ecae5 100644 --- a/web/src/app/api/model-endpoints/usage/route.ts +++ b/web/src/app/api/model-endpoints/usage/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../../research/_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function GET(req: Request) { const url = new URL(req.url) diff --git a/web/src/app/api/newsletter/subscribe/route.ts b/web/src/app/api/newsletter/subscribe/route.ts index db7f6794..251555c2 100644 --- a/web/src/app/api/newsletter/subscribe/route.ts +++ b/web/src/app/api/newsletter/subscribe/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../../research/_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function POST(req: Request) { return proxyJson(req, `${apiBaseUrl()}/api/newsletter/subscribe`, "POST") diff --git a/web/src/app/api/newsletter/subscribers/route.ts b/web/src/app/api/newsletter/subscribers/route.ts index e96390bc..1d4df259 100644 --- a/web/src/app/api/newsletter/subscribers/route.ts +++ b/web/src/app/api/newsletter/subscribers/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../../research/_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function GET(req: Request) { return proxyJson(req, `${apiBaseUrl()}/api/newsletter/subscribers`, "GET") diff --git a/web/src/app/api/papers/[paperId]/save/route.ts b/web/src/app/api/papers/[paperId]/save/route.ts index 494b4ee3..a604f4bf 100644 --- a/web/src/app/api/papers/[paperId]/save/route.ts +++ b/web/src/app/api/papers/[paperId]/save/route.ts @@ -1,5 +1,5 @@ import { NextResponse } from "next/server" -import { apiBaseUrl, proxyJson } from "../../../research/_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" // Validate paperId to prevent path traversal attacks function validatePaperId(paperId: string): number | null { diff --git a/web/src/app/api/papers/library/route.ts b/web/src/app/api/papers/library/route.ts index c1e7cb9f..eec6265d 100644 --- a/web/src/app/api/papers/library/route.ts +++ b/web/src/app/api/papers/library/route.ts @@ -1,4 +1,4 @@ -import { apiBaseUrl, proxyJson } from "../../research/_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function GET(req: Request) { const url = new URL(req.url) diff --git a/web/src/app/api/research/_base.ts b/web/src/app/api/research/_base.ts deleted file mode 100644 index 54bafb03..00000000 --- a/web/src/app/api/research/_base.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { - apiBaseUrl as sharedApiBaseUrl, - proxyJson as sharedProxyJson, - type ProxyMethod, -} from "../_utils/backend-proxy" - -export function apiBaseUrl(): string { - return sharedApiBaseUrl() -} - -export function proxyJson( - req: Request, - upstreamUrl: string, - method: ProxyMethod, -): Promise { - return sharedProxyJson(req, upstreamUrl, method, { auth: true }) -} diff --git a/web/src/app/api/research/collections/[collectionId]/items/[paperId]/route.ts b/web/src/app/api/research/collections/[collectionId]/items/[paperId]/route.ts index b6cc9304..f66b1697 100644 --- a/web/src/app/api/research/collections/[collectionId]/items/[paperId]/route.ts +++ b/web/src/app/api/research/collections/[collectionId]/items/[paperId]/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../../../../_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" interface Context { params: Promise<{ collectionId: string; paperId: string }> diff --git a/web/src/app/api/research/collections/[collectionId]/items/route.ts b/web/src/app/api/research/collections/[collectionId]/items/route.ts index 7d8e5f4f..a1611102 100644 --- a/web/src/app/api/research/collections/[collectionId]/items/route.ts +++ b/web/src/app/api/research/collections/[collectionId]/items/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../../../_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" interface Context { params: Promise<{ collectionId: string }> diff --git a/web/src/app/api/research/collections/[collectionId]/route.ts b/web/src/app/api/research/collections/[collectionId]/route.ts index 83847cf5..f37de7d8 100644 --- a/web/src/app/api/research/collections/[collectionId]/route.ts +++ b/web/src/app/api/research/collections/[collectionId]/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../../_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" interface Context { params: Promise<{ collectionId: string }> diff --git a/web/src/app/api/research/collections/route.ts b/web/src/app/api/research/collections/route.ts index 317ec626..8c531edd 100644 --- a/web/src/app/api/research/collections/route.ts +++ b/web/src/app/api/research/collections/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function GET(req: Request) { const url = new URL(req.url) diff --git a/web/src/app/api/research/context/route.ts b/web/src/app/api/research/context/route.ts index 7157120c..78275c71 100644 --- a/web/src/app/api/research/context/route.ts +++ b/web/src/app/api/research/context/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function POST(req: Request) { return proxyJson(req, `${apiBaseUrl()}/api/research/context`, "POST") diff --git a/web/src/app/api/research/deadlines/radar/route.ts b/web/src/app/api/research/deadlines/radar/route.ts index 515ac901..6d808d2f 100644 --- a/web/src/app/api/research/deadlines/radar/route.ts +++ b/web/src/app/api/research/deadlines/radar/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../../_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function GET(req: Request) { const url = new URL(req.url) diff --git a/web/src/app/api/research/discovery/seed/route.ts b/web/src/app/api/research/discovery/seed/route.ts index 6a1ab2eb..23a4b2da 100644 --- a/web/src/app/api/research/discovery/seed/route.ts +++ b/web/src/app/api/research/discovery/seed/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../../_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function POST(req: Request) { return proxyJson(req, `${apiBaseUrl()}/api/research/discovery/seed`, "POST") diff --git a/web/src/app/api/research/evals/summary/route.ts b/web/src/app/api/research/evals/summary/route.ts index 55984a58..e23c0af0 100644 --- a/web/src/app/api/research/evals/summary/route.ts +++ b/web/src/app/api/research/evals/summary/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../../_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function GET(req: Request) { const url = new URL(req.url) diff --git a/web/src/app/api/research/integrations/zotero/pull/route.ts b/web/src/app/api/research/integrations/zotero/pull/route.ts index 7481f4b2..c667fbd0 100644 --- a/web/src/app/api/research/integrations/zotero/pull/route.ts +++ b/web/src/app/api/research/integrations/zotero/pull/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../../../_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function POST(req: Request) { return proxyJson(req, `${apiBaseUrl()}/api/research/integrations/zotero/pull`, "POST") diff --git a/web/src/app/api/research/integrations/zotero/push/route.ts b/web/src/app/api/research/integrations/zotero/push/route.ts index 6f5ef6a6..162994af 100644 --- a/web/src/app/api/research/integrations/zotero/push/route.ts +++ b/web/src/app/api/research/integrations/zotero/push/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../../../_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function POST(req: Request) { return proxyJson(req, `${apiBaseUrl()}/api/research/integrations/zotero/push`, "POST") diff --git a/web/src/app/api/research/memory/bulk_moderate/route.ts b/web/src/app/api/research/memory/bulk_moderate/route.ts index 0c4e5ed0..0a812a6f 100644 --- a/web/src/app/api/research/memory/bulk_moderate/route.ts +++ b/web/src/app/api/research/memory/bulk_moderate/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../../_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function POST(req: Request) { return proxyJson(req, `${apiBaseUrl()}/api/research/memory/bulk_moderate`, "POST") diff --git a/web/src/app/api/research/memory/bulk_move/route.ts b/web/src/app/api/research/memory/bulk_move/route.ts index b2090b02..8699594b 100644 --- a/web/src/app/api/research/memory/bulk_move/route.ts +++ b/web/src/app/api/research/memory/bulk_move/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../../_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function POST(req: Request) { return proxyJson(req, `${apiBaseUrl()}/api/research/memory/bulk_move`, "POST") diff --git a/web/src/app/api/research/memory/inbox/route.ts b/web/src/app/api/research/memory/inbox/route.ts index e009b1dd..2d71f13c 100644 --- a/web/src/app/api/research/memory/inbox/route.ts +++ b/web/src/app/api/research/memory/inbox/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../../_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function GET(req: Request) { const url = new URL(req.url) diff --git a/web/src/app/api/research/memory/items/[itemId]/moderate/route.ts b/web/src/app/api/research/memory/items/[itemId]/moderate/route.ts index 58e13c1b..783a9b19 100644 --- a/web/src/app/api/research/memory/items/[itemId]/moderate/route.ts +++ b/web/src/app/api/research/memory/items/[itemId]/moderate/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../../../../_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function POST(req: Request, ctx: { params: Promise<{ itemId: string }> }) { const { itemId } = await ctx.params diff --git a/web/src/app/api/research/memory/suggest/route.ts b/web/src/app/api/research/memory/suggest/route.ts index 85152c83..535ba7f0 100644 --- a/web/src/app/api/research/memory/suggest/route.ts +++ b/web/src/app/api/research/memory/suggest/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../../_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function POST(req: Request) { return proxyJson(req, `${apiBaseUrl()}/api/research/memory/suggest`, "POST") diff --git a/web/src/app/api/research/papers/[paperId]/card/route.ts b/web/src/app/api/research/papers/[paperId]/card/route.ts index 010543a6..78eab9c4 100644 --- a/web/src/app/api/research/papers/[paperId]/card/route.ts +++ b/web/src/app/api/research/papers/[paperId]/card/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "@/app/api/research/_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function GET( req: Request, diff --git a/web/src/app/api/research/papers/[paperId]/route.ts b/web/src/app/api/research/papers/[paperId]/route.ts index 565b86d1..7f875716 100644 --- a/web/src/app/api/research/papers/[paperId]/route.ts +++ b/web/src/app/api/research/papers/[paperId]/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../../_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function GET( req: Request, diff --git a/web/src/app/api/research/papers/[paperId]/status/route.ts b/web/src/app/api/research/papers/[paperId]/status/route.ts index b8c340ee..e0d10c1b 100644 --- a/web/src/app/api/research/papers/[paperId]/status/route.ts +++ b/web/src/app/api/research/papers/[paperId]/status/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../../../_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function POST( req: Request, diff --git a/web/src/app/api/research/papers/feedback/route.ts b/web/src/app/api/research/papers/feedback/route.ts index f53dba5c..a49735ec 100644 --- a/web/src/app/api/research/papers/feedback/route.ts +++ b/web/src/app/api/research/papers/feedback/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../../_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function POST(req: Request) { return proxyJson(req, `${apiBaseUrl()}/api/research/papers/feedback`, "POST") diff --git a/web/src/app/api/research/papers/import/bibtex/route.ts b/web/src/app/api/research/papers/import/bibtex/route.ts index b2cdc686..3f1f04ed 100644 --- a/web/src/app/api/research/papers/import/bibtex/route.ts +++ b/web/src/app/api/research/papers/import/bibtex/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../../../_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function POST(req: Request) { return proxyJson(req, `${apiBaseUrl()}/api/research/papers/import/bibtex`, "POST") diff --git a/web/src/app/api/research/papers/related-work/route.ts b/web/src/app/api/research/papers/related-work/route.ts index 99f776f1..2eb3e5f9 100644 --- a/web/src/app/api/research/papers/related-work/route.ts +++ b/web/src/app/api/research/papers/related-work/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "@/app/api/research/_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function POST(req: Request) { return proxyJson( diff --git a/web/src/app/api/research/papers/saved/route.ts b/web/src/app/api/research/papers/saved/route.ts index d3446de3..27ee2db0 100644 --- a/web/src/app/api/research/papers/saved/route.ts +++ b/web/src/app/api/research/papers/saved/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../../_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function GET(req: Request) { const url = new URL(req.url) diff --git a/web/src/app/api/research/paperscool/approvals/route.ts b/web/src/app/api/research/paperscool/approvals/route.ts index 4a182cd7..e70ce497 100644 --- a/web/src/app/api/research/paperscool/approvals/route.ts +++ b/web/src/app/api/research/paperscool/approvals/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "@/app/api/research/_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function GET(req: Request) { const url = new URL(req.url) diff --git a/web/src/app/api/research/paperscool/repos/route.ts b/web/src/app/api/research/paperscool/repos/route.ts index 53800506..5094ce56 100644 --- a/web/src/app/api/research/paperscool/repos/route.ts +++ b/web/src/app/api/research/paperscool/repos/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../../_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function POST(req: Request) { return proxyJson(req, `${apiBaseUrl()}/api/research/paperscool/repos`, "POST") diff --git a/web/src/app/api/research/paperscool/search/route.ts b/web/src/app/api/research/paperscool/search/route.ts index 0c0ddae6..ad4651b2 100644 --- a/web/src/app/api/research/paperscool/search/route.ts +++ b/web/src/app/api/research/paperscool/search/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../../_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function POST(req: Request) { return proxyJson(req, `${apiBaseUrl()}/api/research/paperscool/search`, "POST") diff --git a/web/src/app/api/research/paperscool/sessions/[sessionId]/approve/route.ts b/web/src/app/api/research/paperscool/sessions/[sessionId]/approve/route.ts index 0f0dba8e..23436a69 100644 --- a/web/src/app/api/research/paperscool/sessions/[sessionId]/approve/route.ts +++ b/web/src/app/api/research/paperscool/sessions/[sessionId]/approve/route.ts @@ -1,4 +1,4 @@ -import { apiBaseUrl, proxyJson } from "@/app/api/research/_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export const runtime = "nodejs" diff --git a/web/src/app/api/research/paperscool/sessions/[sessionId]/reject/route.ts b/web/src/app/api/research/paperscool/sessions/[sessionId]/reject/route.ts index cef3afb0..cce4be34 100644 --- a/web/src/app/api/research/paperscool/sessions/[sessionId]/reject/route.ts +++ b/web/src/app/api/research/paperscool/sessions/[sessionId]/reject/route.ts @@ -1,4 +1,4 @@ -import { apiBaseUrl, proxyJson } from "@/app/api/research/_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export const runtime = "nodejs" diff --git a/web/src/app/api/research/repro/context/[packId]/observation/[observationId]/route.ts b/web/src/app/api/research/repro/context/[packId]/observation/[observationId]/route.ts index a380e38d..b77207aa 100644 --- a/web/src/app/api/research/repro/context/[packId]/observation/[observationId]/route.ts +++ b/web/src/app/api/research/repro/context/[packId]/observation/[observationId]/route.ts @@ -1,4 +1,4 @@ -import { apiBaseUrl, proxyJson } from "../../../../../_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" import type { NextRequest } from "next/server" export const runtime = "nodejs" diff --git a/web/src/app/api/research/repro/context/[packId]/route.ts b/web/src/app/api/research/repro/context/[packId]/route.ts index ecf46381..0f246a78 100644 --- a/web/src/app/api/research/repro/context/[packId]/route.ts +++ b/web/src/app/api/research/repro/context/[packId]/route.ts @@ -1,6 +1,6 @@ import type { NextRequest } from "next/server" -import { apiBaseUrl, proxyJson } from "../../../_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function GET(req: NextRequest, { params }: { params: Promise<{ packId: string }> }) { const { packId } = await params diff --git a/web/src/app/api/research/repro/context/[packId]/session/route.ts b/web/src/app/api/research/repro/context/[packId]/session/route.ts index 94955e49..c683a3b9 100644 --- a/web/src/app/api/research/repro/context/[packId]/session/route.ts +++ b/web/src/app/api/research/repro/context/[packId]/session/route.ts @@ -1,6 +1,6 @@ import type { NextRequest } from "next/server" -import { apiBaseUrl, proxyJson } from "../../../../_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function POST(req: NextRequest, { params }: { params: Promise<{ packId: string }> }) { const { packId } = await params diff --git a/web/src/app/api/research/repro/context/route.test.ts b/web/src/app/api/research/repro/context/route.test.ts index 9fe00aa8..67d5aa1f 100644 --- a/web/src/app/api/research/repro/context/route.test.ts +++ b/web/src/app/api/research/repro/context/route.test.ts @@ -9,7 +9,7 @@ const { proxyStreamMock } = vi.hoisted(() => ({ proxyStreamMock: vi.fn(), })) -vi.mock("../../_base", () => ({ +vi.mock("@/app/api/_utils/auth-json-proxy", () => ({ apiBaseUrl: researchApiBaseUrlMock, proxyJson: proxyJsonMock, })) diff --git a/web/src/app/api/research/repro/context/route.ts b/web/src/app/api/research/repro/context/route.ts index b1a340ad..a3103f57 100644 --- a/web/src/app/api/research/repro/context/route.ts +++ b/web/src/app/api/research/repro/context/route.ts @@ -1,4 +1,4 @@ -import { apiBaseUrl, proxyJson } from "../../_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" import { proxyStream } from "@/app/api/_utils/backend-proxy" export const runtime = "nodejs" diff --git a/web/src/app/api/research/router/suggest/route.ts b/web/src/app/api/research/router/suggest/route.ts index e8b24ae1..508d99b8 100644 --- a/web/src/app/api/research/router/suggest/route.ts +++ b/web/src/app/api/research/router/suggest/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../../_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function POST(req: Request) { return proxyJson(req, `${apiBaseUrl()}/api/research/router/suggest`, "POST") diff --git a/web/src/app/api/research/scholar/network/route.ts b/web/src/app/api/research/scholar/network/route.ts index 203c2119..77d9b855 100644 --- a/web/src/app/api/research/scholar/network/route.ts +++ b/web/src/app/api/research/scholar/network/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../../_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function POST(req: Request) { return proxyJson(req, `${apiBaseUrl()}/api/research/scholar/network`, "POST") diff --git a/web/src/app/api/research/scholar/trends/route.ts b/web/src/app/api/research/scholar/trends/route.ts index 737da1ba..4be74526 100644 --- a/web/src/app/api/research/scholar/trends/route.ts +++ b/web/src/app/api/research/scholar/trends/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../../_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function POST(req: Request) { return proxyJson(req, `${apiBaseUrl()}/api/research/scholar/trends`, "POST") diff --git a/web/src/app/api/research/scholars/[scholarRef]/route.ts b/web/src/app/api/research/scholars/[scholarRef]/route.ts index e42033e9..9b0187f9 100644 --- a/web/src/app/api/research/scholars/[scholarRef]/route.ts +++ b/web/src/app/api/research/scholars/[scholarRef]/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../../_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function PATCH(req: Request, context: { params: Promise<{ scholarRef: string }> }) { const params = await context.params diff --git a/web/src/app/api/research/scholars/route.ts b/web/src/app/api/research/scholars/route.ts index 342569d1..afcf7d98 100644 --- a/web/src/app/api/research/scholars/route.ts +++ b/web/src/app/api/research/scholars/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function GET(req: Request) { const url = new URL(req.url) diff --git a/web/src/app/api/research/scholars/search/route.ts b/web/src/app/api/research/scholars/search/route.ts index 1f1c7ef5..cdadd74a 100644 --- a/web/src/app/api/research/scholars/search/route.ts +++ b/web/src/app/api/research/scholars/search/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../../_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function GET(req: Request) { const url = new URL(req.url) diff --git a/web/src/app/api/research/tracks/[trackId]/activate/route.ts b/web/src/app/api/research/tracks/[trackId]/activate/route.ts index e14522cc..28f60f5a 100644 --- a/web/src/app/api/research/tracks/[trackId]/activate/route.ts +++ b/web/src/app/api/research/tracks/[trackId]/activate/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../../../_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function POST(req: Request, ctx: { params: Promise<{ trackId: string }> }) { const { trackId } = await ctx.params diff --git a/web/src/app/api/research/tracks/[trackId]/anchors/[authorId]/action/route.ts b/web/src/app/api/research/tracks/[trackId]/anchors/[authorId]/action/route.ts index 8bc1f5b0..d8ba2b4b 100644 --- a/web/src/app/api/research/tracks/[trackId]/anchors/[authorId]/action/route.ts +++ b/web/src/app/api/research/tracks/[trackId]/anchors/[authorId]/action/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../../../../../_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function POST(req: Request, ctx: { params: Promise<{ trackId: string; authorId: string }> }) { const { trackId, authorId } = await ctx.params diff --git a/web/src/app/api/research/tracks/[trackId]/anchors/actions/route.ts b/web/src/app/api/research/tracks/[trackId]/anchors/actions/route.ts index fab01154..3e4e2a3f 100644 --- a/web/src/app/api/research/tracks/[trackId]/anchors/actions/route.ts +++ b/web/src/app/api/research/tracks/[trackId]/anchors/actions/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../../../../_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function GET(req: Request, ctx: { params: Promise<{ trackId: string }> }) { const { trackId } = await ctx.params diff --git a/web/src/app/api/research/tracks/[trackId]/anchors/discover/route.ts b/web/src/app/api/research/tracks/[trackId]/anchors/discover/route.ts index 40d1671d..ab5712bf 100644 --- a/web/src/app/api/research/tracks/[trackId]/anchors/discover/route.ts +++ b/web/src/app/api/research/tracks/[trackId]/anchors/discover/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../../../../_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function GET(req: Request, ctx: { params: Promise<{ trackId: string }> }) { const { trackId } = await ctx.params diff --git a/web/src/app/api/research/tracks/[trackId]/context/route.ts b/web/src/app/api/research/tracks/[trackId]/context/route.ts index 1ecb8cd9..5fd5b556 100644 --- a/web/src/app/api/research/tracks/[trackId]/context/route.ts +++ b/web/src/app/api/research/tracks/[trackId]/context/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../../../_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function GET(req: Request, ctx: { params: Promise<{ trackId: string }> }) { const { trackId } = await ctx.params diff --git a/web/src/app/api/research/tracks/[trackId]/feed/route.ts b/web/src/app/api/research/tracks/[trackId]/feed/route.ts index 328d0865..47b9f40d 100644 --- a/web/src/app/api/research/tracks/[trackId]/feed/route.ts +++ b/web/src/app/api/research/tracks/[trackId]/feed/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../../../_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function GET(req: Request, ctx: { params: Promise<{ trackId: string }> }) { const { trackId } = await ctx.params diff --git a/web/src/app/api/research/tracks/[trackId]/memory/clear/route.ts b/web/src/app/api/research/tracks/[trackId]/memory/clear/route.ts index d10a503d..fec23a2b 100644 --- a/web/src/app/api/research/tracks/[trackId]/memory/clear/route.ts +++ b/web/src/app/api/research/tracks/[trackId]/memory/clear/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../../../../_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function POST(req: Request, ctx: { params: Promise<{ trackId: string }> }) { const { trackId } = await ctx.params diff --git a/web/src/app/api/research/tracks/[trackId]/route.ts b/web/src/app/api/research/tracks/[trackId]/route.ts index 71e079df..141d7172 100644 --- a/web/src/app/api/research/tracks/[trackId]/route.ts +++ b/web/src/app/api/research/tracks/[trackId]/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../../_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function PATCH(req: Request, ctx: { params: Promise<{ trackId: string }> }) { const { trackId } = await ctx.params diff --git a/web/src/app/api/research/tracks/[trackId]/tasks/route.ts b/web/src/app/api/research/tracks/[trackId]/tasks/route.ts index 882c9eb2..3d372049 100644 --- a/web/src/app/api/research/tracks/[trackId]/tasks/route.ts +++ b/web/src/app/api/research/tracks/[trackId]/tasks/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../../../_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function GET(req: Request, ctx: { params: Promise<{ trackId: string }> }) { const { trackId } = await ctx.params diff --git a/web/src/app/api/research/tracks/active/route.ts b/web/src/app/api/research/tracks/active/route.ts index 38130d40..a8b0dfa6 100644 --- a/web/src/app/api/research/tracks/active/route.ts +++ b/web/src/app/api/research/tracks/active/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../../_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function GET(req: Request) { const url = new URL(req.url) diff --git a/web/src/app/api/research/tracks/route.ts b/web/src/app/api/research/tracks/route.ts index 30887641..a7a22961 100644 --- a/web/src/app/api/research/tracks/route.ts +++ b/web/src/app/api/research/tracks/route.ts @@ -1,6 +1,6 @@ export const runtime = "nodejs" -import { apiBaseUrl, proxyJson } from "../_base" +import { apiBaseUrl, proxyJson } from "@/app/api/_utils/auth-json-proxy" export async function GET(req: Request) { const url = new URL(req.url)