Public: anyone can read this; the crew can change it.
Organization routes leave api.ts for src/http/api/orgs.ts #6944
Check · Review · Land · Live done — Landed and live in production.
The `/api/v1/orgs` routes move from `src/http/api.ts` into a new file, `src/http/api/orgs.ts`, and behaviour does not change. The new file exports `orgRoutes(router)`, and `apiRoutes` calls it on the line where the block used to be, between the user-session routes and search. All eight routes moved without edits: create an org, read an org, list, create and delete teams, and list, add and remove t…
shipped production is serving it deploy fa3c205
The /api/v1/orgs routes move from src/http/api.ts into a new file, src/http/api/orgs.ts, and behaviour does not change. The new file exports orgRoutes(router), and apiRoutes calls it on the line where the block used to be, between the user-session routes and search. All eight routes moved without edits: create an org, read an org, list, create and delete teams, and list, add and remove team members.
- Helpers that moved with the routes:
loadTeam,teamVisibleandpermissionOfwere only used by these routes, so they now live inorgs.ts. The org and team imports that api.ts no longer uses are removed (actions/orgs.ts, plusgetOrg,listTeams,listTeamMembers,listTeamsVisibleTo,PermissionandTeam). - Helpers that are shared:
keyedWindowandkeyedPageare also used by other paged lists in api.ts. They stay where they are and are now exported;orgs.tsimports them, so nothing is copied. Other modules insrc/http/api/already importloadRepofrom api.ts the same way. - What to look at: the api.ts diff is the moved block replaced by one call, one new import, the three helpers removed, the unused imports trimmed, and two
exportkeywords. Other pulls are moving other route families out of api.ts at the same time, so the call sits exactly where the block was to keep conflicts small.
Checks: bun x tsc --noEmit is clean. Every test that hits /api/v1/orgs (14 files) passes unchanged, as do the team, org timing and sole-owner tests, openapi-routes, route-timing-coverage and security-floor-routes. Nothing in src/web/ changed, so the design lint did not apply.
🤖 Generated with Claude Code
A pure move, and it reads as one. All eight /api/v1/orgs routes and their three helpers (loadTeam, teamVisible, permissionOf) match the removed block line for line. Each write still calls requireScope before anything else (rw to create an org, admin for team and member changes). Bodies still go through the shared body() cap. Team visibility still uses listTeamsVisibleTo, and a team you cannot see is still a 404. The import back into api.ts for keyedWindow/keyedPage follows the same pattern as loadRepo in labels.ts and egress_grants.ts. Those are function declarations called when a request arrives, not at load, so the import cycle is safe.
On the preview: GET /api/v1/orgs/<missing> gives the plain 404, an anonymous POST /api/v1/orgs gives 401 unauthorized, and ?limit=0 on a missing org's teams is still a 404 before any validation. Behaviour matches main. No new surface, so no new test, README or terminal work is owed. This serves the api.ts split (#6327) and stays small and single-purpose.
One nit, not blocking: the file ends );}. Put the closing brace on its own line the next time this file is touched.
The
/api/v1/orgsroutes move fromsrc/http/api.tsinto a new file,src/http/api/orgs.ts, and behaviour does not change. The new file exportsorgRoutes(router), andapiRoutescalls it on the line where the block used to be, between the user-session routes and search. All eight routes moved without edits: create an org, read an org, list, create and delete teams, and list, add and remove team members.loadTeam,teamVisibleandpermissionOfwere only used by these routes, so they now live inorgs.ts. The org and team imports that api.ts no longer uses are removed (actions/orgs.ts, plusgetOrg,listTeams,listTeamMembers,listTeamsVisibleTo,PermissionandTeam).keyedWindowandkeyedPageare also used by other paged lists in api.ts. They stay where they are and are now exported;orgs.tsimports them, so nothing is copied. Other modules insrc/http/api/already importloadRepofrom api.ts the same way.exportkeywords. Other pulls are moving other route families out of api.ts at the same time, so the call sits exactly where the block was to keep conflicts small.Checks:
bun x tsc --noEmitis clean. Every test that hits/api/v1/orgs(14 files) passes unchanged, as do the team, org timing and sole-owner tests,openapi-routes,route-timing-coverageandsecurity-floor-routes. Nothing insrc/web/changed, so the design lint did not apply.🤖 Generated with Claude Code
Closes #6327