From 542c359f666585c3a2f08496ad9a10bf065f0682 Mon Sep 17 00:00:00 2001 From: Arvin Xu Date: Tue, 1 Oct 2024 17:41:38 +0800 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor:=20move=20most=20?= =?UTF-8?q?`/api`=20to=20`/webapi`=20(#4233)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ♻️ refactor: /api to /webapi * ✅ test: fix tests --- .../{api => webapi}/assistant/[id]/route.ts | 0 .../{api => webapi}/assistant/store/route.ts | 0 .../{api => webapi}/plugin/gateway/route.ts | 0 .../plugin/gateway/settings.test.ts | 0 .../plugin/gateway/settings.ts | 0 src/app/{api => webapi}/plugin/store/route.ts | 0 .../text-to-image/[provider]/route.ts | 0 src/app/{api => webapi}/trace/route.ts | 0 src/services/__tests__/assistant.test.ts | 4 ++-- src/services/__tests__/tool.test.ts | 2 +- src/services/_url.ts | 24 +++++++++---------- 11 files changed, 15 insertions(+), 15 deletions(-) rename src/app/{api => webapi}/assistant/[id]/route.ts (100%) rename src/app/{api => webapi}/assistant/store/route.ts (100%) rename src/app/{api => webapi}/plugin/gateway/route.ts (100%) rename src/app/{api => webapi}/plugin/gateway/settings.test.ts (100%) rename src/app/{api => webapi}/plugin/gateway/settings.ts (100%) rename src/app/{api => webapi}/plugin/store/route.ts (100%) rename src/app/{api => webapi}/text-to-image/[provider]/route.ts (100%) rename src/app/{api => webapi}/trace/route.ts (100%) diff --git a/src/app/api/assistant/[id]/route.ts b/src/app/webapi/assistant/[id]/route.ts similarity index 100% rename from src/app/api/assistant/[id]/route.ts rename to src/app/webapi/assistant/[id]/route.ts diff --git a/src/app/api/assistant/store/route.ts b/src/app/webapi/assistant/store/route.ts similarity index 100% rename from src/app/api/assistant/store/route.ts rename to src/app/webapi/assistant/store/route.ts diff --git a/src/app/api/plugin/gateway/route.ts b/src/app/webapi/plugin/gateway/route.ts similarity index 100% rename from src/app/api/plugin/gateway/route.ts rename to src/app/webapi/plugin/gateway/route.ts diff --git a/src/app/api/plugin/gateway/settings.test.ts b/src/app/webapi/plugin/gateway/settings.test.ts similarity index 100% rename from src/app/api/plugin/gateway/settings.test.ts rename to src/app/webapi/plugin/gateway/settings.test.ts diff --git a/src/app/api/plugin/gateway/settings.ts b/src/app/webapi/plugin/gateway/settings.ts similarity index 100% rename from src/app/api/plugin/gateway/settings.ts rename to src/app/webapi/plugin/gateway/settings.ts diff --git a/src/app/api/plugin/store/route.ts b/src/app/webapi/plugin/store/route.ts similarity index 100% rename from src/app/api/plugin/store/route.ts rename to src/app/webapi/plugin/store/route.ts diff --git a/src/app/api/text-to-image/[provider]/route.ts b/src/app/webapi/text-to-image/[provider]/route.ts similarity index 100% rename from src/app/api/text-to-image/[provider]/route.ts rename to src/app/webapi/text-to-image/[provider]/route.ts diff --git a/src/app/api/trace/route.ts b/src/app/webapi/trace/route.ts similarity index 100% rename from src/app/api/trace/route.ts rename to src/app/webapi/trace/route.ts diff --git a/src/services/__tests__/assistant.test.ts b/src/services/__tests__/assistant.test.ts index 9e5fd50feffa..6c7eaaaf95f0 100644 --- a/src/services/__tests__/assistant.test.ts +++ b/src/services/__tests__/assistant.test.ts @@ -33,7 +33,7 @@ describe('AssistantService', () => { // Assert expect(globalHelpers.getCurrentLanguage).toHaveBeenCalled(); - expect(fetch).toHaveBeenCalledWith('/api/assistant/store?locale=tt'); + expect(fetch).toHaveBeenCalledWith('/webapi/assistant/store?locale=tt'); expect(assistantList).toEqual(fakeResponse.agents); }); @@ -63,7 +63,7 @@ describe('AssistantService', () => { // Assert expect(globalHelpers.getCurrentLanguage).toHaveBeenCalled(); - expect(fetch).toHaveBeenCalledWith('/api/assistant/test-assisstant?locale=tt'); + expect(fetch).toHaveBeenCalledWith('/webapi/assistant/test-assisstant?locale=tt'); expect(assistant.identifier).toEqual(fakeResponse.identifier); }); diff --git a/src/services/__tests__/tool.test.ts b/src/services/__tests__/tool.test.ts index 8e69fb997890..d52e2106e545 100644 --- a/src/services/__tests__/tool.test.ts +++ b/src/services/__tests__/tool.test.ts @@ -35,7 +35,7 @@ describe('ToolService', () => { // Assert expect(globalHelpers.getCurrentLanguage).toHaveBeenCalled(); - expect(fetch).toHaveBeenCalledWith('/api/plugin/store?locale=tt'); + expect(fetch).toHaveBeenCalledWith('/webapi/plugin/store?locale=tt'); expect(pluginList).toEqual(fakeResponse.plugins); }); diff --git a/src/services/_url.ts b/src/services/_url.ts index 5b110bef7062..36822db03954 100644 --- a/src/services/_url.ts +++ b/src/services/_url.ts @@ -17,26 +17,26 @@ const mapWithBasePath = (apis: T): T => { }; export const API_ENDPOINTS = mapWithBasePath({ - proxy: '/webapi/proxy', + // chat + chat: (provider: string) => withBasePath(`/api/chat/${provider}`), + chatModels: (provider: string) => withBasePath(`/api/chat/models/${provider}`), oauth: '/api/auth', - // agent markets - assistantStore: '/api/assistant/store', - assistant: (identifier: string) => withBasePath(`/api/assistant/${identifier}`), + proxy: '/webapi/proxy', + + // assistant + assistantStore: '/webapi/assistant/store', + assistant: (identifier: string) => withBasePath(`/webapi/assistant/${identifier}`), // plugins - gateway: '/api/plugin/gateway', - pluginStore: '/api/plugin/store', - - // chat - chat: (provider: string) => withBasePath(`/api/chat/${provider}`), - chatModels: (provider: string) => withBasePath(`/api/chat/models/${provider}`), + gateway: '/webapi/plugin/gateway', + pluginStore: '/webapi/plugin/store', // trace - trace: '/api/trace', + trace: '/webapi/trace', // image - images: '/api/text-to-image/openai', + images: '/webapi/api/text-to-image/openai', // STT stt: '/webapi/stt/openai',