feedback5: merge R1 — server/index.js split into server/http/* modules on plain node:http (same exports, headers and responses)

This commit is contained in:
sganggs committed 2026-10-05 16:13:20 +08:00
commit aef8caef3f
21 files changed
+938 -732

No files matched your search

+3 -2
View File
@@ -1,5 +1,6 @@
// test/build.test.js — the served-runtime build tag (server/index.js computeBuildTag / buildTag): the signal that lets
// an already-open page notice a deploy (public/js/ui/buildGuard.js; /healthz `build`).
// test/build.test.js — the served-runtime build tag (server/http/buildTag.js computeBuildTag / buildTag, exported by
// server/index.js): the signal that lets an already-open page notice a deploy (public/js/ui/buildGuard.js;
// /healthz `build`).
import { test } from 'node:test';
import assert from 'node:assert/strict';
import fs from 'node:fs';
+1 -1
View File
@@ -36,7 +36,7 @@ function walk(dir, ext, out = []) {
return out;
}
/** URL path served by the server → file on disk (mirrors server/index.js mounts). */
/** URL path served by the server → file on disk (mirrors the server/http/static.js mounts). */
function urlPathToFile(urlPath) {
const clean = decodeURIComponent(urlPath.split(/[?#]/)[0]);
if (clean.startsWith('/shared/')) return path.join(ROOT, clean);
+1 -1
View File
@@ -23,7 +23,7 @@ const manifest = {
'ui/battle': { img_chess_level_3: { path: '/assets/local/ui/battle/img_chess_level_3.png', w: 45, h: 45 } },
},
};
// what server/index.js serves when data/local-assets.json is absent
// what the server (server/http/static.js) serves when data/local-assets.json is absent
const EMPTY_LOCAL = { version: 1, source: 'none', count: 0, groups: {} };
let mode = 'ok'; // data/local-assets.json: 'ok' (the manifest above) | 'empty' (the server's stand-in) | 'missing' (404)
+5 -5
View File
@@ -36,9 +36,9 @@ test('CHANGELOG.md opens with the release version, and the README links it', ()
test('the release version is what players see', () => {
assert.match(read('public/js/screens/title.js'), /v\$\{APP_VERSION\}/, 'title screen footer');
assert.ok(!/PROTOCOL v1/.test(read('public/js/screens/title.js')), 'no protocol number posing as a version');
const server = read('server/index.js');
assert.match(server, /Stronghold Protocol: Alliance v\$\{APP_VERSION\}/, 'boot banner');
assert.match(server, /app: APP_VERSION/, '/healthz');
// the server's entry is server/index.js; the banner and /healthz live in server/http/ (boot.js, routes.js)
assert.match(read('server/http/boot.js'), /Stronghold Protocol: Alliance v\$\{APP_VERSION\}/, 'boot banner');
assert.match(read('server/http/routes.js'), /app: APP_VERSION/, '/healthz');
});
test('the English title is the official one: Stronghold Protocol: Alliance (as in the reply to GitHub issue #38, which stays open)', () => {
@@ -47,11 +47,11 @@ test('the English title is the official one: Stronghold Protocol: Alliance (as i
const readme = read('README.md');
assert.match(readme.split('\n')[0], /^# 卫戍协议:盟约 · Stronghold Protocol: Alliance$/, 'README title');
assert.match(readme, /mode \*Stronghold Protocol: Alliance\*/, 'README English summary');
assert.match(read('server/index.js'), /卫戍协议:盟约 · Stronghold Protocol: Alliance v/, 'boot banner');
assert.match(read('server/http/boot.js'), /卫戍协议:盟约 · Stronghold Protocol: Alliance v/, 'boot banner');
assert.equal(pkg.name, 'stronghold-protocol-alliance');
assert.equal(lock.name, pkg.name);
assert.equal(lock.packages[''].name, pkg.name);
for (const f of ['README.md', 'server/index.js', 'package.json', 'package-lock.json', 'NOTICE.md', 'public/index.html', 'docs/DEPLOY.md']) {
for (const f of ['README.md', 'server/index.js', 'server/http/boot.js', 'package.json', 'package-lock.json', 'NOTICE.md', 'public/index.html', 'docs/DEPLOY.md']) {
assert.ok(!/covenant/i.test(read(f)), `${f}: no "Covenant" title left`);
}
});