Skip to content

Commit

Permalink
♻️ refactor: move most /api to /webapi (lobehub#4233)
Browse files Browse the repository at this point in the history
* ♻️ refactor: /api to /webapi

* ✅ test: fix tests
  • Loading branch information
arvinxx authored Oct 1, 2024
1 parent 160b490 commit 542c359
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 15 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/services/__tests__/assistant.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand Down Expand Up @@ -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);
});

Expand Down
2 changes: 1 addition & 1 deletion src/services/__tests__/tool.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand Down
24 changes: 12 additions & 12 deletions src/services/_url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,26 @@ const mapWithBasePath = <T extends object>(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',
Expand Down

0 comments on commit 542c359

Please sign in to comment.