feat: scaffold quiz API vertical slice

- Add GameRequestSchema and derived types to packages/shared
- Add SupportedLanguageCode, SupportedPos, DifficultyLevel type exports
- Add getGameTerms() model to packages/db with pos/language/difficulty/limit filters
- Add prepareGameQuestions() service skeleton in apps/api
- Add createGame controller with Zod safeParse validation
- Wire POST /api/v1/game/start route
- Add scripts/gametest/test-game.ts for manual end-to-end testing
This commit is contained in:
lila 2026-04-09 13:47:01 +02:00
parent 13cc709b09
commit 9fc3ba375a
11 changed files with 99 additions and 94 deletions

View file

@ -9,3 +9,5 @@ config({
});
export const db = drizzle(process.env["DATABASE_URL"]!);
export { getGameTerms } from "./models/termModel.js";

View file

@ -0,0 +1,32 @@
import { db } from "@glossa/db";
import { eq, and } from "drizzle-orm";
import { terms, translations } from "@glossa/db/schema";
import type {
SupportedLanguageCode,
SupportedPos,
DifficultyLevel,
} from "@glossa/shared";
export const getGameTerms = async (
sourceLanguage: SupportedLanguageCode,
targetLanguage: SupportedLanguageCode,
pos: SupportedPos,
difficulty: DifficultyLevel,
count: number,
) => {
const rows = await db
.select()
.from(terms)
.innerJoin(translations, eq(translations.term_id, terms.id))
.where(
and(
eq(terms.pos, pos),
eq(translations.language_code, targetLanguage),
eq(translations.difficulty, difficulty),
),
)
.limit(count);
return rows;
};