Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Antonelli-Tech-Solutions/spades/llms.txt

Use this file to discover all available pages before exploring further.

Spades Online is a single Node.js process that serves the web client, HTTP API, and WebSocket connections all on one port — no separate build step required. It can be deployed as a unified service on any Node.js host, or split across two platforms: Vercel handles the static web client and HTTP API routes while Railway runs the WebSocket server separately. Both models are fully supported and share the same codebase.

Prerequisites

Before deploying, make sure you have the following ready:
  • Node.js 18+ — the server is ES Module-only ("type": "module") and targets Node.js 18 or later
  • PostgreSQL — any cloud-managed instance (Railway, Supabase, Neon, RDS) or self-hosted; used for persistent player and game data
  • Redis — any cloud-managed instance (Railway, Upstash, Redis Cloud) or self-hosted; used for session state, lobby presence, pub/sub, and rate limiting
Deploy Spades Online on your own Linux server (or any machine with Node.js installed) behind a reverse proxy for TLS termination.
1

Clone the repository

git clone https://github.com/Antonelli-Tech-Solutions/spades.git
cd spades
2

Install dependencies

npm install
3

Set environment variables

Export the required variables before starting the server. At minimum, DATABASE_URL and REDIS_URL are required:
export DATABASE_URL="postgresql://user:password@localhost:5432/spades"
export REDIS_URL="redis://localhost:6379"
export PORT=3000
export NODE_ENV=production
export APP_URL="https://spades.example.com"
See the full environment variable reference below for the complete list of optional variables.
4

Run database migrations

Apply all migration files in order against your PostgreSQL instance:
psql $DATABASE_URL -f db/migrations/001_create_players.sql
psql $DATABASE_URL -f db/migrations/002_create_profile_and_games.sql
psql $DATABASE_URL -f db/migrations/003_create_password_reset_tokens.sql
psql $DATABASE_URL -f db/migrations/004_create_friendships.sql
psql $DATABASE_URL -f db/migrations/005_create_player_blocks.sql
5

Start the server

npm start
This runs node server/app.js. The server listens on PORT (default 3000) and serves the web client, all API routes, and the WebSocket endpoint on the same port.
6

Configure a reverse proxy for TLS

For production, run Spades Online behind nginx or Caddy to handle TLS termination and forward traffic to the Node.js process.Example Caddy configuration:
spades.example.com {
  reverse_proxy localhost:3000
}
WebSocket upgrade requests are proxied automatically by both nginx and Caddy when using a standard reverse_proxy or proxy_pass directive — no special WebSocket-specific configuration is needed as long as the WebSocket server shares the HTTP port (the default).

Environment Variables

The full set of environment variables supported by Spades Online:
VariableRequiredDefaultDescription
DATABASE_URLYesPostgreSQL connection string
REDIS_URLYesRedis connection string
PORTNo3000HTTP server port
WS_PORTNoSame as PORTWebSocket server port. Defaults to sharing the HTTP server. Set to a different port to run WebSocket on a dedicated server (requires a reverse proxy to route WebSocket upgrades).
WS_URLNoDerived from request originFull WebSocket base URL (e.g. wss://my-app.up.railway.app). Required in split-host deployments. Injected as window.__WS_URL__ in the served HTML.
NODE_ENVNoEnvironment name (development, production)
APP_URLNohttp://localhost:3000Public base URL used in verification emails and join links
EMAIL_HOSTNoSMTP host. If unset, verification emails are logged to stdout
EMAIL_PORTNo587SMTP port
EMAIL_SECURENofalseSet true for TLS on port 465
EMAIL_USERNoSMTP username
EMAIL_PASSNoSMTP password
EMAIL_FROMNonoreply@spades.onlineFrom address for outbound email
GIT_COMMIT_SHANoCurrent commit SHA (set by CI). Falls back to VERCEL_GIT_COMMIT_SHA, then COMMIT_REF, then git rev-parse HEAD
AUTH_RATE_LIMIT_MAXNo10Max auth requests per window
AUTH_RATE_LIMIT_WINDOWNo900Rate limit window in seconds (default: 15 minutes)
DEV_AUTO_VERIFYNoSkip email verification on registration. Local dev only.
Never set DEV_AUTO_VERIFY=true in production. It completely disables email verification, allowing any registration to skip the email confirmation step. This is a local development convenience only.

Rate Limiting

Spades Online uses a Redis-backed fixed-window rate limiter on authentication endpoints. The limiter tracks requests per IP address using a Redis key with an automatic TTL. The defaults are configurable via environment variables:
VariableDefaultDescription
AUTH_RATE_LIMIT_MAX10Maximum number of requests allowed per window
AUTH_RATE_LIMIT_WINDOW900Window duration in seconds (900 s = 15 minutes)
When a request exceeds the limit, the server returns HTTP 429 with the response body:
{ "error": "Too many requests. Please try again later." }
The following rate-limit headers are included on every auth response:
HeaderDescription
X-RateLimit-LimitMaximum requests allowed in the window
X-RateLimit-RemainingRequests remaining in the current window
X-RateLimit-ResetUnix timestamp when the window resets
If Redis is not configured (REDIS_URL is not set), the rate limiter middleware is bypassed and all requests are passed through without limiting. Ensure Redis is available in all production environments.

Health Check

The server exposes a lightweight build-info endpoint that can be used as a health check or version probe:
GET /api/build-info
Response:
{ "commitShort": "a1b2c3d" }
Returns the short (7-character) git commit SHA of the running server. If GIT_COMMIT_SHA is not set and the SHA cannot be resolved from the environment or git rev-parse HEAD, the response is { "commitShort": null }. Use this endpoint in your load balancer, uptime monitor, or deployment pipeline to confirm the correct version is running after a deploy.

Build docs developers (and LLMs) love