-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor client API mocks and imports
- Loading branch information
Showing
8 changed files
with
47 additions
and
18 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { createOpenApiHttp } from "openapi-msw"; | ||
|
||
import { type GalaxyApiPaths } from "@/api/schema"; | ||
|
||
function createApiClientMock() { | ||
return createOpenApiHttp<GalaxyApiPaths>(); | ||
} | ||
|
||
let clientMock: ReturnType<typeof createApiClientMock>; | ||
|
||
export function useClientApiMock() { | ||
if (!clientMock) { | ||
clientMock = createApiClientMock(); | ||
} | ||
|
||
return { clientMock }; | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import createClient from "openapi-fetch"; | ||
|
||
import { type GalaxyApiPaths } from "@/api/schema"; | ||
import { getAppRoot } from "@/onload/loadConfig"; | ||
|
||
function createApiClient() { | ||
return createClient<GalaxyApiPaths>({ baseUrl: getAppRoot(undefined, true) }); | ||
} | ||
|
||
let client: ReturnType<typeof createApiClient>; | ||
|
||
export function useClientApi() { | ||
if (!client) { | ||
client = createApiClient(); | ||
} | ||
|
||
return { client }; | ||
} |
8 changes: 6 additions & 2 deletions
8
client/src/api/schema/mockClient.test.ts → client/src/api/client/mockClient.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,3 @@ | ||
import createClient from "openapi-fetch"; | ||
|
||
import { getAppRoot } from "@/onload/loadConfig"; | ||
|
||
import { type components, type paths as GalaxyApiPaths } from "./schema"; | ||
|
||
export { type components, type GalaxyApiPaths }; | ||
|
||
export const client = createClient<GalaxyApiPaths>({ baseUrl: getAppRoot(undefined, true) }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters