elysia is the truth
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
"build": "vite build"
|
||||
},
|
||||
"dependencies": {
|
||||
"@elysiajs/eden": "^1.3.2",
|
||||
"@solidjs/router": "^0.15.3",
|
||||
"hono": "^4.8.12",
|
||||
"solid-js": "^1.9.5"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { hc } from "hono/client";
|
||||
import { type ApiType } from "../../server/src/api";
|
||||
import { type Api } from "../../server/src/api";
|
||||
import { treaty } from "@elysiajs/eden";
|
||||
|
||||
export default hc<ApiType>("http://localhost:5001/api");
|
||||
const { api } = treaty<Api>("http://localhost:5001");
|
||||
export default api;
|
||||
|
||||
@@ -1,23 +1,8 @@
|
||||
import {
|
||||
Accessor,
|
||||
createContext,
|
||||
createEffect,
|
||||
createResource,
|
||||
JSX,
|
||||
Show,
|
||||
Suspense,
|
||||
} from "solid-js";
|
||||
import Card from "./Card";
|
||||
import { Accessor, createContext, createResource, Show } from "solid-js";
|
||||
import { GameState } from "../../../shared/types/cards";
|
||||
import api from "../api";
|
||||
import Hand from "./Hand";
|
||||
import Pile from "./Pile";
|
||||
import {
|
||||
GameState,
|
||||
newDeck,
|
||||
shuffle,
|
||||
Hand as THand,
|
||||
} from "../../../shared/types/cards";
|
||||
import { createStore, produce, SetStoreFunction, Store } from "solid-js/store";
|
||||
import api from "../api";
|
||||
|
||||
export const GameContext = createContext<{
|
||||
gameState: Accessor<GameState | undefined>;
|
||||
@@ -25,17 +10,18 @@ export const GameContext = createContext<{
|
||||
}>();
|
||||
|
||||
export default (props: { instanceId: number }) => {
|
||||
const [gameState, { refetch }] = createResource<GameState>(() =>
|
||||
api.gameState[":gameId"]
|
||||
.$get({ param: { gameId: props.instanceId.toString() } })
|
||||
.then((res) => res.json())
|
||||
const [gameState, { refetch }] = createResource(() =>
|
||||
api
|
||||
.gameState({ gameId: props.instanceId.toString() })
|
||||
.get()
|
||||
.then((res) => res.data as GameState)
|
||||
);
|
||||
|
||||
const setGameState = (state: GameState) =>
|
||||
api.gameState[":gameId"]
|
||||
.$put({
|
||||
param: { gameId: props.instanceId.toString() },
|
||||
json: state,
|
||||
api
|
||||
.gameState({ gameId: props.instanceId.toString() })
|
||||
.put({
|
||||
gameState: state,
|
||||
})
|
||||
.then(refetch);
|
||||
|
||||
|
||||
@@ -8,8 +8,7 @@ export default () => {
|
||||
|
||||
const [instances, { refetch }] = createResource(
|
||||
() => param.game,
|
||||
async () =>
|
||||
api.instances.$get({ query: param }).then((res) => res.json())
|
||||
async () => api.instances.get({ query: param }).then((res) => res.data)
|
||||
);
|
||||
|
||||
return (
|
||||
|
||||
@@ -4,7 +4,7 @@ import api from "../api";
|
||||
|
||||
export default () => {
|
||||
const [games] = createResource(async () =>
|
||||
api.games.$get().then((res) => res.json())
|
||||
api.games.get().then((res) => res.data)
|
||||
);
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user