diff --git a/apps/api/src/gameSessionStore/GameSessionStore.ts b/apps/api/src/gameSessionStore/GameSessionStore.ts new file mode 100644 index 0000000..766f26c --- /dev/null +++ b/apps/api/src/gameSessionStore/GameSessionStore.ts @@ -0,0 +1,7 @@ +export type GameSessionData = { answers: Map }; + +export interface GameSessionStore { + create(sessionId: string, data: GameSessionData): Promise; + get(sessionId: string): Promise; + delete(sessionId: string): Promise; +} diff --git a/apps/api/src/gameSessionStore/InMemoryGameSessionStore.ts b/apps/api/src/gameSessionStore/InMemoryGameSessionStore.ts new file mode 100644 index 0000000..d4a339c --- /dev/null +++ b/apps/api/src/gameSessionStore/InMemoryGameSessionStore.ts @@ -0,0 +1,17 @@ +import type { GameSessionStore, GameSessionData } from "./GameSessionStore.js"; + +export class InMemoryGameSessionStore implements GameSessionStore { + private sessions = new Map(); + + async create(sessionId: string, data: GameSessionData): Promise { + this.sessions.set(sessionId, data); + } + + async get(sessionId: string): Promise { + return this.sessions.get(sessionId) ?? null; + } + + async delete(sessionId: string): Promise { + this.sessions.delete(sessionId); + } +} diff --git a/apps/api/src/gameSessionStore/index.ts b/apps/api/src/gameSessionStore/index.ts new file mode 100644 index 0000000..c01f457 --- /dev/null +++ b/apps/api/src/gameSessionStore/index.ts @@ -0,0 +1,2 @@ +export type { GameSessionStore, GameSessionData } from "./GameSessionStore.js"; +export { InMemoryGameSessionStore } from "./InMemoryGameSessionStore.js"; diff --git a/apps/api/tsconfig.json b/apps/api/tsconfig.json index 2a60b18..52192c0 100644 --- a/apps/api/tsconfig.json +++ b/apps/api/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "references": [ { "path": "../../packages/shared" }, - { "path": "../../packages/db" } + { "path": "../../packages/db" }, ], "compilerOptions": { "module": "NodeNext", @@ -10,7 +10,7 @@ "outDir": "./dist", "resolveJsonModule": true, "rootDir": ".", - "types": ["vitest/globals"] + "types": ["vitest/globals"], }, - "include": ["src", "vitest.config.ts", "../../packages/db/src/models"] + "include": ["src", "vitest.config.ts"], } diff --git a/package.json b/package.json index 2fbc788..704311f 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "description": "a vocabulary trainer", "private": true, "scripts": { + "build": "pnpm --filter @glossa/shared build && pnpm --filter @glossa/db build", "dev": "concurrently --names \"api,web\" -c \"magenta.bold,green.bold\" \"pnpm --filter @glossa/api dev\" \"pnpm --filter @glossa/web dev\"", "test": "vitest", "test:run": "vitest run", diff --git a/packages/db/src/generating-deck.ts b/packages/db/src/generating-deck.ts index 4699047..5bd63d4 100644 --- a/packages/db/src/generating-deck.ts +++ b/packages/db/src/generating-deck.ts @@ -103,7 +103,7 @@ const createDeck = async (tx: DbOrTx, validatedLanguages: string[]) => { description: config.deckDescription, source_language: config.sourceLanguage, validated_languages: validatedLanguages, - is_public: false, + type: "core", }) .returning({ id: decks.id }); const created = result[0];