Files
supabase/apps/studio/api/server.js
T
7d3f72ec7d feat(studio): TanStack project routes — data surfaces (stack 5.1/6, from #46424) (#47117)
**Stack 5.1/6** of the TanStack Start migration (#46424). The original
S5 (174 files) was over CodeRabbit's 150-file review cap, so it's split
into 5.1 + 5.2 by product. Stacked on **#47113** (S4).

> [!NOTE]
> Thin route wrappers rendering the existing pages-router components via
compat shims. Next-safe (full Next build run). The TanStack app isn't
functional end-to-end until 5.2 + the matrix flip.

## What's in this PR
- **Data-cluster project routes:** database, editor, sql, storage,
realtime, branches.
- **Top-level / onboarding routes:** `authorize`, `join`, `logout`,
`redeem`, `verify-email`, `claim-project`, aws-marketplace,
Vercel/GitHub integration entrypoints; `_app`/`_auth` layout shells;
`/org/_` + `/project/_` catch-alls.
- **Supporting edits:** hoist `BranchesPageWrapper` out of `getLayout`,
`ConnectStepsSection` `import.meta.glob`, `api/server.js`.
- `routeTree.gen.ts` regenerated for the routes present so far.

## Verification
On top of S1–S4: `studio` typecheck ✓, lint (0 errors) ✓, **Next build ✓
(181/181 pages)**.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Refactor**
* Restructured application routing infrastructure for improved code
organization and maintainability.
* Extracted and refactored layout wrapper components for enhanced
reusability across different sections of the application.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Alaister Young <10985857+alaister@users.noreply.github.com>
Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
2026-07-03 21:22:06 +08:00

26 lines
1.3 KiB
JavaScript

// STUDIO_FRAMEWORK gates whether this function actually serves the TanStack
// SSR handler. Vercel auto-detects every file under /api as a Function
// regardless of the framework preset (vercel.com/docs/functions), so we
// can't keep this file from being deployed in the Next.js prod build — we
// just make it inert when the env var is unset.
const isTanstack = process.env.STUDIO_FRAMEWORK === 'tanstack'
// Computed path keeps `dist/server/server.js` out of Vercel's function
// bundler's static analysis. In the Next.js prod deploy the `dist/` tree
// doesn't exist, but Vercel still bundles this file because it lives under
// `api/`. With the .join() the bundler treats the import as runtime-only
// and the missing dist/ isn't a build error. In TanStack mode the SSR
// bundle is shipped into the function via the `functions['api/server.js']
// .includeFiles` config in vercel.ts.
const tanstackEntry = ['..', 'dist', 'server', 'server.js'].join('/')
const handler = isTanstack
? (await import(tanstackEntry)).default
: { fetch: () => new Response('Not Found', { status: 404 }) }
// Vercel's Web API handler convention: export an object with `fetch(request)`.
// TanStack's server build is already shaped that way — default-export it
// verbatim and Vercel hands us a real Web Request.
// eslint-disable-next-line no-restricted-exports
export default handler