initialize server project with basic structure and dependencies

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
2026-05-02 14:30:20 +02:00
commit 7e2ba65c54
7 changed files with 851 additions and 0 deletions
+46
View File
@@ -0,0 +1,46 @@
# DiscoveryServer
Lightweight Node.js + WebSocket server for ZAMNY co-op matchmaking.
**Responsibilities**:
- Player registry + nicknames (max 16 chars)
- List available players
- Room creation / joining (2-player co-op)
- Relay for initial handshake
**No game logic** (AD-03). All simulation runs client-side.
## Quick Start
```bash
npm install
npm run dev # tsx watch, ws://localhost:3001
npm test # node:test via tsx
npm run build
npm start
```
## WebSocket Protocol
All messages are JSON objects with `type`.
### Client → Server
- `{ "type": "set_nickname", "nickname": "Player1" }`
- `{ "type": "list_players" }`
- `{ "type": "join_room", "target": "p123" }` (TODO)
### Server → Client
- `{ "type": "welcome", "id": "p1" }`
- `{ "type": "nickname_ok", "nickname": "Player1" }`
- `{ "type": "player_list", "players": [{ "id": "p2", "nickname": "ZomSlayer" }] }`
- `{ "type": "error", "message": "..." }`
## Notes
- Pure functions (`validateNickname`, `createRoomId`) are unit-tested.
- Server only starts when run directly (not during tests).
- Port 3001 (hardcoded for now).
- See root [ARCHITECTURE.md](../ARCHITECTURE.md) for full design.