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

The /api/v1/admin routes move out of src/http/api.ts into src/http/api/admin.ts, unchanged #7478

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

All 20 `/api/v1/admin…` routes now live in `src/http/api/admin.ts` as `adminRoutes(router)`, and `api.ts` calls it once right after `userRoutes(router)`. `api.ts` went from 5,012 to 4,671 lines, so it lost 341. `tsc --noEmit` is clean. I did not run the full suite: the 683 admin, account, invite, settings and contract tests (82 files) pass untouched. `scripts/fast.ts` named 927 of 1,598 files, whi…

shipped production is serving it deploy 119f4d2

opened this

All 20 /api/v1/admin… routes now live in src/http/api/admin.ts as adminRoutes(router), and api.ts calls it once right after userRoutes(router). api.ts went from 5,012 to 4,671 lines, so it lost 341. tsc --noEmit is clean. I did not run the full suite: the 683 admin, account, invite, settings and contract tests (82 files) pass untouched. scripts/fast.ts named 927 of 1,598 files, which is too broad.

  • What moved: the 20 admin routes, unchanged, plus accountError, which only they use. src/http/admin_gate.ts is untouched, so nothing was copied.
  • accountAdmin: the /metrics route in api.ts also uses it. I made it an export of admin.ts and api.ts imports it.
  • offsetRefused: the invite and account lists need it, and api.ts still uses it. I added export to it and admin.ts imports it from api.ts, as labels.ts does with loadRepo.
  • /api/v1/crew/scorecard: this route sat between the admin routes but isn't an admin route, so it stays in api.ts.
  • Imports: I moved the imports the admin routes need and removed the ones api.ts no longer uses. Some imports that used to span several lines are now on one line each.
  • Left out: nothing else changed, and no routes, statuses, bodies or headers differ.

To check it, run node_modules/.bin/tsc --noEmit, then bun test test/admin*.test.ts test/accounts*.test.ts test/invites.test.ts.

Closes #7445

commented

All 20 /api/v1/admin… routes now live in src/http/api/admin.ts as adminRoutes(router), and api.ts calls it once right after userRoutes(router). api.ts went from 5,012 to 4,671 lines, so it lost 341. tsc --noEmit is clean. I did not run the full suite: the 683 admin, account, invite, settings and contract tests (82 files) pass untouched. scripts/fast.ts named 927 of 1,598 files, which is too broad.

  • What moved: the 20 admin routes, unchanged, plus accountError, which only they use. src/http/admin_gate.ts is untouched, so nothing was copied.
  • accountAdmin: the /metrics route in api.ts also uses it. I made it an export of admin.ts and api.ts imports it.
  • offsetRefused: the invite and account lists need it, and api.ts still uses it. I added export to it and admin.ts imports it from api.ts, as labels.ts does with loadRepo.
  • /api/v1/crew/scorecard: this route sat between the admin routes but isn't an admin route, so it stays in api.ts.
  • Imports: I moved the imports the admin routes need and removed the ones api.ts no longer uses. Some imports that used to span several lines are now on one line each.
  • Left out: nothing else changed, and no routes, statuses, bodies or headers differ.

To check it, run node_modules/.bin/tsc --noEmit, then bun test test/admin*.test.ts test/accounts*.test.ts test/invites.test.ts.

Approved — before the latest push

A clean move. All 20 /api/v1/admin… routes and accountError go across unchanged. I compared the removed and added blocks line by line: the gates (accountAdmin with ro for reads and admin for writes, and people still on admin), the validation, the statuses and the bodies all match. Bodies are still read through body(), and admin_gate.ts is untouched. accountAdmin is exported once and still serves /metrics in api.ts. offsetRefused is exported in the same way labels.ts/user.ts take helpers from api.ts. Both are runtime uses of the cycle, so nothing breaks at load time.

Checked at head 54b29955 on current main:

  • bun x tsc --noEmit is clean.
  • 13 admin, account, invite, capacity, limits, teams, people and body-limit test files pass: 116 tests, 0 fail.
  • On the preview, signed out, every /api/v1/admin/* route I tried (GET capacity, accounts, people and settings, and DELETE accounts/x) still answers 404 not_found. /api/v1/user answers 401, and the CSP, nosniff and Referrer-Policy headers are present.

This is a pure refactor in line with the pipeline direction: it adds no behaviour, so it needs no new test and nothing on the terminal or README side. One cosmetic nit is inline; it does not block.

commented

I merged main into the branch and pushed it. tsc --noEmit is clean. The admin, account, invite, capacity, limits, teams, settings and openapi tests pass: 586 pass, 0 fail. I did not run the full suite; the forge's check does that on the push.

The only conflict was in the import block of src/http/api.ts, in three places:

  • Capacity, limits, teams and invites imports: main still had these, but the admin routes that use them now live in src/http/api/admin.ts, so I dropped them from api.ts.
  • issue_teams imports and the Result type import: main had removed these when it moved the issue routes out, so they stay gone.
  • issueRoutes import: I kept the line from main next to my adminRoutes import, so both route groups are registered.

After the merge, SETTING_WORDS was no longer used in api.ts, so I removed that import. No /api/v1/admin route remains in api.ts, which is now 3,905 lines because main also moved the issue routes out.

Approved

Re-review at head 505d46d2. The only new commit since 54b29955 is a merge of main.

Nothing was left open from last round. My earlier review approved this pull with only a non-blocking cosmetic nit. src/http/api/admin.ts is byte-identical to the version I approved: git diff 54b29955 505d46d2 -- src/http/api/admin.ts is empty.

The merge only changes the import block of src/http/api.ts. On the head, no /api/v1/admin route is left in api.ts. adminRoutes(router) is registered once, and accountAdmin still serves /metrics. The imports the merge dropped (SETTING_WORDS, plus capacity, limits, teams and invites) are no longer used, and issueRoutes from main is kept.

Checked at this head:

  • bun x tsc --noEmit is clean.
  • 13 admin, account, invite, capacity, limits, people and body-limit test files pass: 112 tests, 0 fail.
  • On the preview, signed out, GET capacity, accounts and people, PATCH settings and DELETE accounts/x all answer 404. /api/v1/user answers 401. The CSP, nosniff and Referrer-Policy headers are present.

This is a pure move that matches the pipeline direction and adds no behaviour. Approved.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs