Public: anyone can read this; the crew can change it.

Migrated from github.com/Trevato/SO-ARM100

Relay's GET /admin page is served from src/admin-routes.ts - no behaviour change #133

Merged opened this

Check · Review · Land done · Live — Landed; nothing deploys from this branch, so this is the end of its path.

Merged

GET /admin and its 401/403 refusals are now served from a new src/admin-routes.ts, and relay.ts calls it. I couldn't run bun x tsc --noEmit here. Bun couldn't write to its temp directory, even for bun install.

Notes

shipped merged

opened this

GET /admin and its 401/403 refusals are now served from a new src/admin-routes.ts, and relay.ts calls it. I couldn't run bun x tsc --noEmit here. Bun couldn't write to its temp directory, even for bun install. I checked the types by reading instead, so the forge's check is the first real type check.

src/admin-relay.test.ts, src/relay.test.ts and src/admin.test.ts pass untouched: 26 tests, 0 failures.

  • New function: serveAdminPage(lobby, req, res, url) sends the refusal for anyone not allowed, and the page for GET and HEAD. For any other method by an allowed caller, it hands back { who, canEdit, show, refuse } so the POST handler in relay.ts can carry on.
  • Unchanged: The POST actions stay in relay.ts with no behaviour change. The issue said to pass json and readBody into the new function as arguments. The new function never needs them, because the 405 and the form-size handling stay in relay.ts.

I wrote this fresh rather than reusing the earlier #107 branch. That branch isn't in this clone, so I couldn't check it.

🤖 Generated with Claude Code

Closes #121

2 earlier comments
commented

GET /admin and its 401/403 refusals are now served from a new src/admin-routes.ts, and relay.ts calls it. I couldn't run bun x tsc --noEmit here. Bun couldn't write to its temp directory, even for bun install. I checked the types by reading instead, so the forge's check is the first real type check.

src/admin-relay.test.ts, src/relay.test.ts and src/admin.test.ts pass untouched: 26 tests, 0 failures.

  • New function: serveAdminPage(lobby, req, res, url) sends the refusal for anyone not allowed, and the page for GET and HEAD. For any other method by an allowed caller, it hands back { who, canEdit, show, refuse } so the POST handler in relay.ts can carry on.
  • Unchanged: The POST actions stay in relay.ts with no behaviour change. The issue said to pass json and readBody into the new function as arguments. The new function never needs them, because the 405 and the form-size handling stay in relay.ts.

I wrote this fresh rather than reusing the earlier #107 branch. That branch isn't in this clone, so I couldn't check it.

🤖 Generated with Claude Code

commented

GET /admin and its 401/403 refusals are now served from a new src/admin-routes.ts, and relay.ts calls it. The POST actions stay in relay.ts with no behaviour change.

  • Check failure: forge.json declared check.limits but no check.run, so the check had nothing to run. I added check.run: install with the frozen lockfile, then bun x tsc --noEmit, then bun test, all from Software/so101. I picked those commands myself, because the repo's docs name none. I couldn't run the check here, so the forge's run on this push is the first real one.
  • Tests: src/admin-relay.test.ts, src/relay.test.ts and src/admin.test.ts pass untouched (26 tests).
  • Type check: bun x tsc --noEmit wouldn't run in my sandbox, because Bun couldn't write to its temp directory. I checked the types by reading only.
  • Shape of the new module: serveAdminPage(lobby, req, res, url) answers the refusals and GET/HEAD itself. For any other method from an allowed caller it returns { who, canEdit, show, refuse } for the POST handler. json and readBody are not passed in, because the new function never needs them.

🤖 Generated with Claude Code

commented

GET /admin and its 401/403 refusals are now served from a new src/admin-routes.ts, and relay.ts calls it. The POST actions stay in relay.ts with no behaviour change.

  • Why the check failed: My earlier forge.json edit added check.run, and main had since removed the whole check block (commit 1142ee6). The two edits to the same file conflicted. I took main's forge.json as it is and merged main in, so this branch no longer touches forge.json.
  • Diff against main: It is now only src/admin-routes.ts (new) and the relay.ts change.
  • Tests: I didn't re-run them after the merge, because nothing in the source changed. Before it, src/admin-relay.test.ts, src/relay.test.ts and src/admin.test.ts passed untouched (26 tests).
  • Type check: bun x tsc --noEmit won't run in my sandbox, because Bun can't write its temp directory. I checked the types by reading only, so the forge's check is the first real type check.
  • New function: serveAdminPage(lobby, req, res, url) answers the refusals and GET/HEAD itself. For any other method from an allowed caller it returns { who, canEdit, show, refuse } for the POST handler. json and readBody are not passed in, because the new function never needs them.

🤖 Generated with Claude Code

Approved

Pure move: the identity, moderator-verification and refusal logic is byte-for-byte the same, POST handling stays in relay.ts, and the diff is only admin-routes.ts plus the relay call site. Preview /admin answers 401 with the admin CSP, no-store, nosniff and referrer headers; / answers 200. Existing admin/relay tests cover the behaviour and no new behaviour was added. Next: (1) serveAdminPage returns a session for POST and null for already-answered, which is a surprising contract for a function named serve*; rename it or split the gate from the page. (2) Add a direct unit test for the gate (guest 401, non-owner 403, moderator needing a verified id) so it does not depend on the relay harness.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs