Examples > text-adventures COMPANION SERVER.JS (1/13) File: examples/companions/text-adventures/server.js (403 lines) // Text adventure server for the CrossPoint "text-adventures" example plugin. // // node server.js (PORT=8095, GAMES_DIR=./games, DATA_DIR=./data) // // Put .z3/.z5/.z8 (or .zblorb) files into games/ (see fetch-games.sh). The server // runs the games itself (zmachine.js) and turns every turn into catalog rows for // the reader: // // GET /games list picker: one list per game // GET /s//view?game= the current turn as rows (sets the active game) // GET /s//cmd?q= Search box = type a command; answers with rows // GET /s//do?g=&t=&c= a quick-command row's Details page (HTML) // GET /s//out?g=&t= a past turn's text (HTML) // GET /s//transcript.txt the Fetch button: the whole game as a .txt // // Every request loads the game state from DATA_DIR, runs one command and saves it // again. Nothing is kept in memory between requests except the story files. import fs from 'node:fs'; import path from 'node:path'; import http from 'node:http'; import crypto from 'node:crypto'; import { fileURLToPath } from 'node:url'; import { ZMachine, ZError } from './zmachine.js'; Next: 10 Companion server.js (2/13)