Skip to content

Installation ​

Requirements ​

  • Node.js >= 20.9.0
  • MySQL / MariaDB
  • Redis — required for matchmaking / chat queues; optional if you only exercise HTTP. Enable Redis before using MatchmakingDemo.

Install dependencies ​

bash
npm install

Environment variables ​

Create .env.development (local) or .env.production in the server repo root. Load order is described in the Chinese Configuration page (first sections).

Minimal example below; replace your_* placeholders with your MySQL credentials and a strong secret.

VariableWhat it is
NODE_ENVNode environment. development selects .env.development and dev-oriented behaviour in src/config.
PORTSingle port for HTTP + Colyseus WebSocket (default 2567 → http://localhost:2567, Swagger /api-docs, etc.).
DB_HOSTMySQL / MariaDB host (localhost on your machine).
DB_PORTDatabase port (3306 for MySQL by default).
DB_USERNAME / DB_PASSWORDDB login; never commit real passwords.
DB_DATABASEDatabase schema name (create the empty DB first). Entities/migrations: see project-structure docs (Chinese).
JWT_SECRETSymmetric secret used to sign access tokens (same tokens required by @RequireAuth() room options). Use a long random string in production.
JWT_EXPIRES_INAccess-token lifetime string (1h, 24h, …) passed to jsonwebtoken expiresIn. Refresh tokens / JWT_REFRESH_*: see “Redis 与 JWT” in Configuration.

Redis, DB_TYPE, DB_SYNCHRONIZE, and the rest are listed in Configuration.

env
NODE_ENV=development
PORT=2567

DB_HOST=localhost
DB_PORT=3306
DB_USERNAME=root
DB_PASSWORD=your_password
DB_DATABASE=your_database

JWT_SECRET=your_jwt_secret_key
JWT_EXPIRES_IN=1h

Run dev server ​

bash
npm run dev

Verify ​

Visit http://localhost:2567/api-docs and the static home page. For Colyseus rooms, follow Quick start step 3–4.

Translation status

The longest environment tables live in the Chinese configuration page: 配置说明 →.

English pages are partial; authoritative docs are in Simplified Chinese.