@supabase/server 1.1.0-rc.65 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -63,4 +63,5 @@ function withSupabase(config) {
63
63
  }
64
64
 
65
65
  //#endregion
66
+ exports.SupabaseError = SupabaseError;
66
67
  exports.withSupabase = withSupabase;
@@ -1,7 +1,6 @@
1
1
  import { t as AuthError } from "../../errors-fa-CyugW.cjs";
2
2
  import { d as SupabaseContext, m as WithSupabaseConfig } from "../../types-CwKZOVIv.cjs";
3
- import * as elysia from "elysia";
4
- import { Elysia } from "elysia";
3
+ import { Elysia, ExtractErrorFromHandle } from "elysia";
5
4
 
6
5
  //#region src/adapters/elysia/plugin.d.ts
7
6
  declare class SupabaseError extends Error {
@@ -52,7 +51,7 @@ declare class SupabaseError extends Error {
52
51
  * app.listen(3000)
53
52
  * ```
54
53
  */
55
- declare function withSupabase(config?: Omit<WithSupabaseConfig, 'cors'>): Elysia<"", {
54
+ declare function withSupabase(config?: Omit<WithSupabaseConfig, 'cors'>): Elysia<'', {
56
55
  decorator: {};
57
56
  store: {};
58
57
  derive: {};
@@ -76,7 +75,7 @@ declare function withSupabase(config?: Omit<WithSupabaseConfig, 'cors'>): Elysia
76
75
  };
77
76
  schema: {};
78
77
  standaloneSchema: {};
79
- response: elysia.ExtractErrorFromHandle<{
78
+ response: ExtractErrorFromHandle<{
80
79
  supabaseContext: SupabaseContext;
81
80
  }>;
82
81
  }, {
@@ -87,4 +86,4 @@ declare function withSupabase(config?: Omit<WithSupabaseConfig, 'cors'>): Elysia
87
86
  response: {};
88
87
  }>;
89
88
  //#endregion
90
- export { withSupabase };
89
+ export { SupabaseError, withSupabase };
@@ -1,7 +1,6 @@
1
1
  import { t as AuthError } from "../../errors-C43um2Gg.mjs";
2
2
  import { d as SupabaseContext, m as WithSupabaseConfig } from "../../types-DbvLfq25.mjs";
3
- import * as elysia from "elysia";
4
- import { Elysia } from "elysia";
3
+ import { Elysia, ExtractErrorFromHandle } from "elysia";
5
4
 
6
5
  //#region src/adapters/elysia/plugin.d.ts
7
6
  declare class SupabaseError extends Error {
@@ -52,7 +51,7 @@ declare class SupabaseError extends Error {
52
51
  * app.listen(3000)
53
52
  * ```
54
53
  */
55
- declare function withSupabase(config?: Omit<WithSupabaseConfig, 'cors'>): Elysia<"", {
54
+ declare function withSupabase(config?: Omit<WithSupabaseConfig, 'cors'>): Elysia<'', {
56
55
  decorator: {};
57
56
  store: {};
58
57
  derive: {};
@@ -76,7 +75,7 @@ declare function withSupabase(config?: Omit<WithSupabaseConfig, 'cors'>): Elysia
76
75
  };
77
76
  schema: {};
78
77
  standaloneSchema: {};
79
- response: elysia.ExtractErrorFromHandle<{
78
+ response: ExtractErrorFromHandle<{
80
79
  supabaseContext: SupabaseContext;
81
80
  }>;
82
81
  }, {
@@ -87,4 +86,4 @@ declare function withSupabase(config?: Omit<WithSupabaseConfig, 'cors'>): Elysia
87
86
  response: {};
88
87
  }>;
89
88
  //#endregion
90
- export { withSupabase };
89
+ export { SupabaseError, withSupabase };
@@ -62,4 +62,4 @@ function withSupabase(config) {
62
62
  }
63
63
 
64
64
  //#endregion
65
- export { withSupabase };
65
+ export { SupabaseError, withSupabase };
@@ -44,13 +44,14 @@ let h3 = require("h3");
44
44
  */
45
45
  function withSupabase(config) {
46
46
  return (0, h3.defineMiddleware)(async (event, next) => {
47
- if (event.context.supabaseContext) return next();
47
+ const context = event.context;
48
+ if (context.supabaseContext) return next();
48
49
  const { data: ctx, error } = await require_create_supabase_context.createSupabaseContext(event.req, config);
49
50
  if (error) throw new h3.HTTPError(error.message, {
50
51
  status: error.status,
51
52
  cause: error
52
53
  });
53
- event.context.supabaseContext = ctx;
54
+ context.supabaseContext = ctx;
54
55
  return next();
55
56
  });
56
57
  }
@@ -1,4 +1,4 @@
1
- import { d as SupabaseContext, m as WithSupabaseConfig } from "../../types-CwKZOVIv.cjs";
1
+ import { m as WithSupabaseConfig } from "../../types-CwKZOVIv.cjs";
2
2
  import { Middleware } from "h3";
3
3
 
4
4
  //#region src/adapters/h3/middleware.d.ts
@@ -42,10 +42,5 @@ import { Middleware } from "h3";
42
42
  * ```
43
43
  */
44
44
  declare function withSupabase(config?: Omit<WithSupabaseConfig, 'cors'>): Middleware;
45
- declare module 'h3' {
46
- interface H3EventContext {
47
- supabaseContext: SupabaseContext;
48
- }
49
- }
50
45
  //#endregion
51
46
  export { withSupabase };
@@ -1,4 +1,4 @@
1
- import { d as SupabaseContext, m as WithSupabaseConfig } from "../../types-DbvLfq25.mjs";
1
+ import { m as WithSupabaseConfig } from "../../types-DbvLfq25.mjs";
2
2
  import { Middleware } from "h3";
3
3
 
4
4
  //#region src/adapters/h3/middleware.d.ts
@@ -42,10 +42,5 @@ import { Middleware } from "h3";
42
42
  * ```
43
43
  */
44
44
  declare function withSupabase(config?: Omit<WithSupabaseConfig, 'cors'>): Middleware;
45
- declare module 'h3' {
46
- interface H3EventContext {
47
- supabaseContext: SupabaseContext;
48
- }
49
- }
50
45
  //#endregion
51
46
  export { withSupabase };
@@ -43,13 +43,14 @@ import { HTTPError, defineMiddleware } from "h3";
43
43
  */
44
44
  function withSupabase(config) {
45
45
  return defineMiddleware(async (event, next) => {
46
- if (event.context.supabaseContext) return next();
46
+ const context = event.context;
47
+ if (context.supabaseContext) return next();
47
48
  const { data: ctx, error } = await createSupabaseContext(event.req, config);
48
49
  if (error) throw new HTTPError(error.message, {
49
50
  status: error.status,
50
51
  cause: error
51
52
  });
52
- event.context.supabaseContext = ctx;
53
+ context.supabaseContext = ctx;
53
54
  return next();
54
55
  });
55
56
  }
@@ -10,6 +10,20 @@ pnpm add h3
10
10
 
11
11
  The adapter exports its own `withSupabase` that returns H3 middleware instead of a fetch handler. Works with standalone H3 servers and Nuxt server routes (which run on H3 under the hood).
12
12
 
13
+ ## Typing `event.context.supabaseContext`
14
+
15
+ The middleware stores the context on `event.context.supabaseContext`. Add this declaration once in your project (e.g. in `types/h3.d.ts`) for typed access:
16
+
17
+ ```ts
18
+ import type { SupabaseContext } from '@supabase/server'
19
+
20
+ declare module 'h3' {
21
+ interface H3EventContext {
22
+ supabaseContext: SupabaseContext
23
+ }
24
+ }
25
+ ```
26
+
13
27
  ## Basic app with auth
14
28
 
15
29
  ```ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supabase/server",
3
- "version": "1.1.0-rc.65",
3
+ "version": "1.1.0",
4
4
  "description": "Server-side utilities for Supabase. Handles auth, client creation, and context injection so you write business logic, not boilerplate.",
5
5
  "keywords": [
6
6
  "edge",