diff options
Diffstat (limited to 'frontend/app/.server/api/client.ts')
| -rw-r--r-- | frontend/app/.server/api/client.ts | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/frontend/app/.server/api/client.ts b/frontend/app/.server/api/client.ts deleted file mode 100644 index fef1508..0000000 --- a/frontend/app/.server/api/client.ts +++ /dev/null @@ -1,51 +0,0 @@ -import createClient from "openapi-fetch"; -import type { paths } from "./schema"; - -const apiClient = createClient<paths>({ - baseUrl: - process.env.NODE_ENV === "development" - ? "http://localhost:8003/phperkaigi/2025/code-battle/api/" - : "http://api-server/phperkaigi/2025/code-battle/api/", -}); - -export async function apiPostLogin(username: string, password: string) { - const { data, error } = await apiClient.POST("/login", { - body: { - username, - password, - }, - }); - if (error) throw new Error(error.message); - return data; -} - -export async function apiGetGames(token: string) { - const { data, error } = await apiClient.GET("/games", { - params: { - header: { Authorization: `Bearer ${token}` }, - }, - }); - if (error) throw new Error(error.message); - return data; -} - -export async function apiGetGame(token: string, gameId: number) { - const { data, error } = await apiClient.GET("/games/{game_id}", { - params: { - header: { Authorization: `Bearer ${token}` }, - path: { game_id: gameId }, - }, - }); - if (error) throw new Error(error.message); - return data; -} - -export async function apiGetToken(token: string) { - const { data, error } = await apiClient.GET("/token", { - params: { - header: { Authorization: `Bearer ${token}` }, - }, - }); - if (error) throw new Error(error.message); - return data; -} |
