Skip to content

feat(adapters): add defineAdapter for uniform framework integrations#71

Open
johnstonmatt wants to merge 4 commits into
mainfrom
FUNC-655/defineAdapter-for-uniform-integrations
Open

feat(adapters): add defineAdapter for uniform framework integrations#71
johnstonmatt wants to merge 4 commits into
mainfrom
FUNC-655/defineAdapter-for-uniform-integrations

Conversation

@johnstonmatt
Copy link
Copy Markdown
Contributor

@johnstonmatt johnstonmatt commented May 26, 2026

This pull request introduces a new, unified adapter pattern for Supabase server framework integrations, specifically refactoring and enhancing the Elysia and H3 adapters, and updating the package exports to expose a shared adapter interface. The main changes add a dual-form withSupabase API to both Elysia and H3 adapters, allowing either plugin/middleware or direct route handler usage, and ensure consistent error handling and context reuse across frameworks. Comprehensive tests are added for the new handler form in Elysia, H3, and Hono. Package exports are updated to expose the new core adapter interface.

Adapter architecture and API improvements

  • Refactored the Elysia (src/adapters/elysia/plugin.ts) and H3 (src/adapters/h3/middleware.ts) adapters to use a new defineAdapter utility from core/adapters, enabling a unified, dual-form withSupabase API. This API supports both plugin/middleware form and direct route handler form, with consistent error handling and context reuse. [1] [2] [3] [4] [5] [6]

  • Enhanced documentation in both adapters to clearly explain the new dual-form API, usage patterns, and error handling expectations. [1] [2] [3]

Testing enhancements

  • Added comprehensive tests for the new two-argument (dual-form) withSupabase handler usage in Elysia (plugin.test.ts), H3 (middleware.test.ts), and Hono (middleware.test.ts), covering context reuse, error propagation, and direct Web Fetch compatibility. [1] [2] [3]

Package and export updates

  • Updated jsr.json and package.json to export the new core/adapters interface, making the adapter utility available for framework integrations. [1] [2]

Documentation and changelog

  • Minor formatting fixes in CHANGELOG.md for consistency.

References: [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]

@johnstonmatt johnstonmatt requested review from a team as code owners May 26, 2026 16:28
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 26, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@supabase/server@71

commit: 7ffbb1e

JSR rejects destructured exports and exports without explicit type
annotations in the public API. Return `withSupabase` directly from
`defineAdapter` (instead of `{ withSupabase }`) and annotate each
adapter's exported `withSupabase` with `AdapterWithSupabase<...>`.
…55/defineAdapter-for-uniform-integrations
Brings the NestJS adapter under the same `defineAdapter` factory used by
Hono, H3, and Elysia. The one-arg guard class behavior is unchanged; the
two-arg dual-mode handler (`Request | ExecutionContext`) is added for
parity with the other adapters.

NestJS intentionally omits `getExistingContext` — guards run in
global → controller → handler order, so a handler-level guard must
always re-evaluate to override what an outer guard set.
johnstonmatt added a commit that referenced this pull request May 28, 2026
PR #71 (on FUNC-655/defineAdapter-for-uniform-integrations) is the
source of truth for the `defineAdapter` API and lands first. Match its
shape on this branch so that once #71 merges to main, no breaking
change ripples through to gates-core consumers:

- `defineAdapter(spec)` returns the overloaded `withSupabase` function
  directly (was: `{ withSupabase }`).
- Adapters annotate the export explicitly:
  `export const withSupabase: AdapterWithSupabase<Ctx, M> = defineAdapter<...>({...})`
  (was: `export const { withSupabase } = defineAdapter<...>({...})`).

The annotation duplication is the price of JSR slow-type compatibility
without the wrapping object. Same trade-off PR #71 already made; this
just keeps the public surface uniform across branches.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant