lots more kefir tinkering
This commit is contained in:
@@ -8,7 +8,7 @@ import {
|
||||
import { human } from "./human";
|
||||
import dayjs from "dayjs";
|
||||
import db from "./db";
|
||||
import { liveTable, WebsocketIncomingMessage } from "./table";
|
||||
import { liveTable, WsOut, WsIn } from "./table";
|
||||
|
||||
const api = new Elysia({ prefix: "/api" })
|
||||
.post("/whoami", async ({ cookie: { token } }) => {
|
||||
@@ -62,11 +62,8 @@ const api = new Elysia({ prefix: "/api" })
|
||||
)
|
||||
.get("/games", () => [{ key: "simple", name: "simple" }])
|
||||
.ws("/ws/:tableKey", {
|
||||
response: t.Object({
|
||||
players: t.Optional(t.Array(t.String())),
|
||||
view: t.Optional(t.Any()),
|
||||
}),
|
||||
body: WebsocketIncomingMessage,
|
||||
response: WsOut,
|
||||
body: WsIn,
|
||||
|
||||
message(
|
||||
{
|
||||
|
||||
@@ -9,11 +9,17 @@ import {
|
||||
} from "./games/simple";
|
||||
import { transform } from "./kefir-extension";
|
||||
|
||||
export const WebsocketIncomingMessage = t.Union([
|
||||
export const WsOut = t.Object({
|
||||
players: t.Optional(t.Array(t.String())),
|
||||
view: t.Optional(t.Any()),
|
||||
});
|
||||
export type TWsOut = typeof WsOut.static;
|
||||
export const WsIn = t.Union([
|
||||
t.Object({ proposeGame: t.String() }),
|
||||
t.Object({ startGame: t.Literal(true) }),
|
||||
t.Object({ action: t.Any() }),
|
||||
]);
|
||||
export type TWsIn = typeof WsIn.static;
|
||||
|
||||
type TablePayload<GameState, GameAction> = {
|
||||
inputs: {
|
||||
|
||||
Reference in New Issue
Block a user