initial commit

This commit is contained in:
2025-10-17 12:28:08 -07:00
commit 2b64ace453
26 changed files with 5493 additions and 0 deletions

35
server/src/index.ts Normal file
View File

@ -0,0 +1,35 @@
import Koa from "koa";
import Router from "@koa/router";
import { Blackjack } from "./blackjack/Blackjack";
import { itemResponse, itemsResponse } from "./serverResponse";
const PORT = 3000;
const app = new Koa();
const router = new Router();
const tables: Blackjack[] = [];
router.get("/table", (ctx) => {
ctx.status = 200;
ctx.body = itemsResponse(tables);
});
router.get("/table/:id", (ctx) => {
const id = ctx.params["id"];
ctx.status = 200;
ctx.body = itemResponse(tables[Number(id)]);
});
router.post("/table", (ctx) => {
const id = tables.length;
tables.push(new Blackjack(id));
ctx.status = 201;
ctx.body = { id };
});
app.use(router.routes());
app.listen(3000, () => console.log(`listening on port ${PORT}`));