refactor: route team bootstrap through dashboard admin API#298
refactor: route team bootstrap through dashboard admin API#298ben-fornefeld merged 11 commits intomainfrom
Conversation
Bootstrap users through the dashboard-api callback and fallback resolver paths, and use the teams repository for create-team instead of direct API calls. Made-with: Cursor
…tup-via-dashboard-api
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR SummaryMedium Risk Overview Updates server flows to pass the authenticated Reviewed by Cursor Bugbot for commit 5e079ff. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 617b36d840
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
Pull request overview
Routes team bootstrap and team creation through the Dashboard Admin/API contracts, ensuring user/team resolution happens via the dashboard API with explicit user context.
Changes:
- Added dashboard admin-token support (env + header helpers) and introduced an AdminUsersRepository for
/admin/users/{userId}/bootstrap. - Updated
resolveUserTeamto acceptuserIdand bootstrap the user when no teams are found. - Moved team creation to
TeamsRepository.createTeam()and updated OpenAPI spec + generated dashboard API types accordingly.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/lib/env.ts | Adds required DASHBOARD_API_ADMIN_TOKEN to server env schema. |
| src/configs/api.ts | Introduces X-Admin-Token header constant + helper. |
| src/core/shared/contracts/dashboard-api.types.ts | Updates generated types to include /teams POST and /admin/users/{userId}/bootstrap plus new/updated schemas. |
| src/core/modules/users/admin-repository.server.ts | New server-only admin users repository to call bootstrap endpoint. |
| src/core/server/functions/team/resolve-user-team.ts | Adds userId param and bootstraps user when team list is empty. |
| src/core/modules/teams/teams-repository.server.ts | Adds createTeam() and makes teamId optional in scope with a runtime guard for team-scoped ops. |
| src/core/modules/teams/user-teams-repository.server.ts | Removes unused secondsInDay import. |
| src/core/server/actions/team-actions.ts | Switches team creation to repository-backed dashboard API call. |
| src/app/api/auth/callback/route.ts | Bootstraps user after auth callback via admin repository. |
| src/app/dashboard/route.ts | Passes userId into resolveUserTeam. |
| src/app/dashboard/account/route.ts | Passes userId into resolveUserTeam. |
| src/app/sbx/new/route.ts | Passes userId into resolveUserTeam. |
| src/test/integration/resolve-user-team.test.ts | Updates tests for new resolveUserTeam(userId, accessToken) signature and bootstrap behavior. |
| src/test/integration/dashboard-route.test.ts | Updates expectation for resolveUserTeam call signature. |
| spec/openapi.dashboard-api.yaml | Adds AdminTokenAuth scheme, /teams POST, and /admin/users/{userId}/bootstrap path; updates UserTeam.createdAt. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 174a35c. Configure here.
| ) | ||
| } | ||
|
|
||
| if (ENABLE_USER_BOOTSTRAP) { |
There was a problem hiding this comment.
why do we need this under a flag?
There was a problem hiding this comment.
only temporary for the migration period

Summary
resolveUserTeam/admin/users/{userId}/bootstrapcontract and update generated API types