feat: refactor Socket.IO server implementation and update README for queue system

This commit is contained in:
2025-09-19 18:51:28 +02:00
parent e60c801f4e
commit ff81967a59
6 changed files with 307 additions and 179 deletions

View File

@@ -47,8 +47,8 @@ This repository contains a minimal demo of a queue system for high-concurrency t
Files added in this demo:
- `server/index.js` — simple Socket.IO server with in-memory queue logic and JWT issuance (demo only).
- `.env.example` — example environment variables for running the socket server.
- `pages/api/socket.js` — Next.js API route with Socket.IO server, in-memory queue logic and JWT issuance (demo only).
- `.env.example` — example environment variables for the queue system.
- `app/page.tsx` — client UI (Next.js) that connects via Socket.IO and displays queue position, estimated wait, and purchase button.
Important notes and limitations:
@@ -59,26 +59,19 @@ Important notes and limitations:
Running locally
1. Copy `.env.example` to `.env` and adjust values (especially `JWT_SECRET`).
2. Install dependencies for the server and client:
2. Install dependencies (already included in package.json):
```powershell
pnpm install
pnpm --filter . add socket.io socket.io-client jsonwebtoken dotenv mysql2
```
3. Start the Socket.IO server:
```powershell
node server/index.js
```
4. Start the Next.js dev server:
3. Start the Next.js dev server (includes the Socket.IO API route):
```powershell
pnpm dev
```
5. Open `http://localhost:3000` and the client will connect to the socket server (default `http://localhost:4000`).
4. Open `http://localhost:3000` and the client will connect to the Socket.IO API route at `/api/socket`.
Next steps / improvements