Add POST /me/join and a join card: accounts survive a world reset

Found while resetting the live test world: joinWorld's comment promised POST /worlds/:id/join but no route existed, so after reset-world (accounts kept) nobody could found a POP again. Added POST /me/join (default: first running world; 409 if already joined), a join card on the POP screen, en/nb strings, API.md + openapi. Client no longer polls /movements while it has no operator (that 404ed).

Tested: npm test 209/209 (new test/me-join.test.js incl. response contract), openapi check, npm run e2e (new check: account without a POP sees the join card and founds one). NOT tested: joining a second/other world (only the default-world path in the browser), nb text of the card visually.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q2MJaQ5LXAHzGnTDgceT14
This commit is contained in:
jvanvik 2026-10-11 22:43:15 +02:00
parent bf7af0679c
commit 9104480463
9 changed files with 170 additions and 6 deletions

View file

@ -25,6 +25,7 @@ REST JSON under `/api/v1/`. The machine-readable contract is `docs/openapi.json`
| `POST /auth/login` | token for another device (`invalid_credentials`, `forbidden` when banned) |
| `GET /auth/tokens`, `DELETE /auth/tokens/:tokenId`, `POST /auth/logout` | list this account's active device tokens, revoke one, revoke the current one |
| `GET /me` | user, operators (per world), POPs |
| `POST /me/join {worldId?}` | an account with no operator (world reset, new world) founds its capital POP (201, returns `/me`); `409 conflict` if already joined |
| `GET /towns/:id` | full POP state: resources `{amount, rate, cap}` at `serverTime`, power, buildings with the server's build plan, queue |
| `POST /towns/:id/build {key}` | build/upgrade one level of a field (`f1..f18`) or an infrastructure building |
| `DELETE /towns/:id/queue/:eventId` | cancel a running build, 80% refund |