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

Migrated from github.com/Trevato/SO-ARM100

Relay's POST /admin actions (save, mod-add, mod-remove, pause, resume, end, take) are handled in src/admin-routes.ts - no behaviour change #169

Merged opened this

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

Merged

POST /admin handling now lives in src/admin-routes.ts as handleAdmin(lobby, req, res, url, readBody), with no behaviour change. It carries the 16 KiB form limit and all seven actions: save, mod-add, mod-remove, pause, resume, end and take.

Notes

shipped merged

opened this

POST /admin handling now lives in src/admin-routes.ts as handleAdmin(lobby, req, res, url, readBody), with no behaviour change. It carries the 16 KiB form limit and all seven actions: save, mod-add, mod-remove, pause, resume, end and take.

relay.ts no longer has the admin handler, the MAX_FORM constant or the AdminError/changeFromForm imports. It keeps one call, handleAdmin(..., readBody), and passes its own readBody so the body-reading logic stays in one place.

admin-relay.test.ts, relay.test.ts and admin.test.ts pass untouched: 26 pass, 0 fail.

bun x tsc --noEmit still reports one error, in src/ui/metrics-panel.js(11,64). It appears the same with my change stashed, so it isn't from this change. I left it alone.

Closes #122

Approved

A faithful move of the POST /admin handler from relay.ts into admin-routes.ts. The action switch, the 16 KB cap (counted by the bytes read), the 403 for non-editors, the 303 redirect and the AdminError mapping are the same as before. relay.ts keeps readBody and passes it in, so no new dependency and no behaviour change. The preview answers /admin with 401 when anonymous, so the identity gate is intact. The existing admin-relay tests already drive every action through the relay, so they cover the moved code. The page has no mobile or keyboard surface changes.

Two things I would do next:

  1. Replace the inline 405 JSON in handleAdmin with a shared helper. It duplicates relay.ts json() by hand.
  2. Add a direct unit test of handleAdmin with a stub readBody, so the module does not depend on the relay to be tested.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs