aboutsummaryrefslogtreecommitdiffhomepage
path: root/frontend/app/.server/api/client.ts
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/app/.server/api/client.ts')
-rw-r--r--frontend/app/.server/api/client.ts130
1 files changed, 65 insertions, 65 deletions
diff --git a/frontend/app/.server/api/client.ts b/frontend/app/.server/api/client.ts
index b3c7e9c..a78180b 100644
--- a/frontend/app/.server/api/client.ts
+++ b/frontend/app/.server/api/client.ts
@@ -2,94 +2,94 @@ import createClient from "openapi-fetch";
import type { operations, paths } from "./schema";
const apiClient = createClient<paths>({
- baseUrl:
- process.env.NODE_ENV === "development"
- ? "http://localhost:8002/api/"
- : "http://api-server/api/",
+ baseUrl:
+ process.env.NODE_ENV === "development"
+ ? "http://localhost:8002/api/"
+ : "http://api-server/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;
+ 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;
+ 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;
+ 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;
+ const { data, error } = await apiClient.GET("/token", {
+ params: {
+ header: { Authorization: `Bearer ${token}` },
+ },
+ });
+ if (error) throw new Error(error.message);
+ return data;
}
export async function adminApiGetUsers(token: string) {
- const { data, error } = await apiClient.GET("/admin/users", {
- params: {
- header: { Authorization: `Bearer ${token}` },
- },
- });
- if (error) throw new Error(error.message);
- return data;
+ const { data, error } = await apiClient.GET("/admin/users", {
+ params: {
+ header: { Authorization: `Bearer ${token}` },
+ },
+ });
+ if (error) throw new Error(error.message);
+ return data;
}
export async function adminApiGetGames(token: string) {
- const { data, error } = await apiClient.GET("/admin/games", {
- params: {
- header: { Authorization: `Bearer ${token}` },
- },
- });
- if (error) throw new Error(error.message);
- return data;
+ const { data, error } = await apiClient.GET("/admin/games", {
+ params: {
+ header: { Authorization: `Bearer ${token}` },
+ },
+ });
+ if (error) throw new Error(error.message);
+ return data;
}
export async function adminApiGetGame(token: string, gameId: number) {
- const { data, error } = await apiClient.GET("/admin/games/{game_id}", {
- params: {
- header: { Authorization: `Bearer ${token}` },
- path: { game_id: gameId },
- },
- });
- if (error) throw new Error(error.message);
- return data;
+ const { data, error } = await apiClient.GET("/admin/games/{game_id}", {
+ params: {
+ header: { Authorization: `Bearer ${token}` },
+ path: { game_id: gameId },
+ },
+ });
+ if (error) throw new Error(error.message);
+ return data;
}
export async function adminApiPutGame(
- token: string,
- gameId: number,
- body: operations["adminPutGame"]["requestBody"]["content"]["application/json"],
+ token: string,
+ gameId: number,
+ body: operations["adminPutGame"]["requestBody"]["content"]["application/json"],
) {
- const { data, error } = await apiClient.PUT("/admin/games/{game_id}", {
- params: {
- header: { Authorization: `Bearer ${token}` },
- path: { game_id: gameId },
- },
- body,
- });
- if (error) throw new Error(error.message);
- return data;
+ const { data, error } = await apiClient.PUT("/admin/games/{game_id}", {
+ params: {
+ header: { Authorization: `Bearer ${token}` },
+ path: { game_id: gameId },
+ },
+ body,
+ });
+ if (error) throw new Error(error.message);
+ return data;
}