@supabase/server 1.2.0-rc.69 → 1.2.0-rc.70

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.
@@ -17,8 +17,15 @@ let hono_factory = require("hono/factory");
17
17
  * ```ts
18
18
  * import { Hono } from 'hono'
19
19
  * import { withSupabase } from '@supabase/server/adapters/hono'
20
+ * import type { SupabaseContext } from '@supabase/server'
20
21
  *
21
- * const app = new Hono()
22
+ * type Env = {
23
+ * Variables: {
24
+ * supabaseContext: SupabaseContext
25
+ * }
26
+ * }
27
+ *
28
+ * const app = new Hono<Env>()
22
29
  * app.use('*', withSupabase({ auth: 'user' }))
23
30
  *
24
31
  * app.get('/profile', async (c) => {
@@ -15,8 +15,15 @@ import { MiddlewareHandler } from "hono";
15
15
  * ```ts
16
16
  * import { Hono } from 'hono'
17
17
  * import { withSupabase } from '@supabase/server/adapters/hono'
18
+ * import type { SupabaseContext } from '@supabase/server'
18
19
  *
19
- * const app = new Hono()
20
+ * type Env = {
21
+ * Variables: {
22
+ * supabaseContext: SupabaseContext
23
+ * }
24
+ * }
25
+ *
26
+ * const app = new Hono<Env>()
20
27
  * app.use('*', withSupabase({ auth: 'user' }))
21
28
  *
22
29
  * app.get('/profile', async (c) => {
@@ -15,8 +15,15 @@ import { MiddlewareHandler } from "hono";
15
15
  * ```ts
16
16
  * import { Hono } from 'hono'
17
17
  * import { withSupabase } from '@supabase/server/adapters/hono'
18
+ * import type { SupabaseContext } from '@supabase/server'
18
19
  *
19
- * const app = new Hono()
20
+ * type Env = {
21
+ * Variables: {
22
+ * supabaseContext: SupabaseContext
23
+ * }
24
+ * }
25
+ *
26
+ * const app = new Hono<Env>()
20
27
  * app.use('*', withSupabase({ auth: 'user' }))
21
28
  *
22
29
  * app.get('/profile', async (c) => {
@@ -16,8 +16,15 @@ import { createMiddleware } from "hono/factory";
16
16
  * ```ts
17
17
  * import { Hono } from 'hono'
18
18
  * import { withSupabase } from '@supabase/server/adapters/hono'
19
+ * import type { SupabaseContext } from '@supabase/server'
19
20
  *
20
- * const app = new Hono()
21
+ * type Env = {
22
+ * Variables: {
23
+ * supabaseContext: SupabaseContext
24
+ * }
25
+ * }
26
+ *
27
+ * const app = new Hono<Env>()
21
28
  * app.use('*', withSupabase({ auth: 'user' }))
22
29
  *
23
30
  * app.get('/profile', async (c) => {
@@ -76,7 +76,7 @@ const { data: users } = await supabaseAdmin.from('profiles').select()
76
76
 
77
77
  ## Using with the Hono adapter
78
78
 
79
- The Hono context variable is typed as `SupabaseContext` (without the generic). To get typed clients, assert the type when destructuring:
79
+ Pass an app environment type to `Hono<Env>()` so Hono knows the `supabaseContext` variable includes your generated database types:
80
80
 
81
81
  ```ts
82
82
  import { Hono } from 'hono'
@@ -84,12 +84,18 @@ import { withSupabase } from '@supabase/server/adapters/hono'
84
84
  import type { SupabaseContext } from '@supabase/server'
85
85
  import type { Database } from './database.types.ts'
86
86
 
87
- const app = new Hono()
87
+ type Env = {
88
+ Variables: {
89
+ supabaseContext: SupabaseContext<Database>
90
+ }
91
+ }
92
+
93
+ const app = new Hono<Env>()
88
94
 
89
95
  app.use('*', withSupabase({ auth: 'user' }))
90
96
 
91
97
  app.get('/todos', async (c) => {
92
- const { supabase } = c.var.supabaseContext as SupabaseContext<Database>
98
+ const { supabase } = c.var.supabaseContext
93
99
  const { data } = await supabase.from('todos').select('id, title')
94
100
  return c.json(data)
95
101
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supabase/server",
3
- "version": "1.2.0-rc.69",
3
+ "version": "1.2.0-rc.70",
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",