Scaffold monorepo: engine, server, and web packages
npm workspaces with three TypeScript packages: @wizwar/engine (pure game logic), @wizwar/server (Node websocket authority), @wizwar/web (Svelte 5 + Vite client). Server handshake and client build verified. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "@wizwar/server",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "tsx watch src/index.ts",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"test": "vitest run"
|
||||
},
|
||||
"dependencies": {
|
||||
"@wizwar/engine": "*",
|
||||
"ws": "^8.18.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.0.0",
|
||||
"@types/ws": "^8.5.0",
|
||||
"tsx": "^4.19.0",
|
||||
"typescript": "^5.6.0",
|
||||
"vitest": "^2.1.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { WebSocketServer } from "ws";
|
||||
|
||||
const port = Number(process.env.PORT ?? 8787);
|
||||
const wss = new WebSocketServer({ port });
|
||||
|
||||
wss.on("connection", (socket) => {
|
||||
socket.send(JSON.stringify({ type: "hello", game: "wizwar" }));
|
||||
socket.on("message", (data) => {
|
||||
// TODO: route client commands into game rooms once the engine exists.
|
||||
console.log("received:", data.toString());
|
||||
});
|
||||
});
|
||||
|
||||
console.log(`wizwar server listening on ws://localhost:${port}`);
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"compilerOptions": {
|
||||
"noEmit": true,
|
||||
"types": ["node"]
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
Reference in New Issue
Block a user