feat(db): add lobbies and lobby_players tables + model
This commit is contained in:
parent
a7be7152cc
commit
47a68c0315
8 changed files with 1310 additions and 10 deletions
|
|
@ -13,3 +13,6 @@ export const SUPPORTED_DECK_TYPES = ["grammar", "media"] as const;
|
|||
|
||||
export const DIFFICULTY_LEVELS = ["easy", "intermediate", "hard"] as const;
|
||||
export type DifficultyLevel = (typeof DIFFICULTY_LEVELS)[number];
|
||||
|
||||
export const LOBBY_STATUSES = ["waiting", "in_progress", "finished"] as const;
|
||||
export type LobbyStatus = (typeof LOBBY_STATUSES)[number];
|
||||
|
|
|
|||
22
packages/shared/src/schemas/lobby.ts
Normal file
22
packages/shared/src/schemas/lobby.ts
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import * as z from "zod";
|
||||
|
||||
import { LOBBY_STATUSES } from "../constants.js";
|
||||
|
||||
export const LobbyPlayerSchema = z.object({
|
||||
lobbyId: z.uuid(),
|
||||
userId: z.string(),
|
||||
score: z.number().int().min(0),
|
||||
user: z.object({ id: z.string(), name: z.string() }),
|
||||
});
|
||||
|
||||
export type LobbyPlayer = z.infer<typeof LobbyPlayerSchema>;
|
||||
|
||||
export const LobbySchema = z.object({
|
||||
id: z.uuid(),
|
||||
code: z.string().min(1).max(10),
|
||||
hostUserId: z.string(),
|
||||
status: z.enum(LOBBY_STATUSES),
|
||||
createdAt: z.iso.datetime(),
|
||||
players: z.array(LobbyPlayerSchema),
|
||||
});
|
||||
export type Lobby = z.infer<typeof LobbySchema>;
|
||||
Loading…
Add table
Add a link
Reference in a new issue