Skip to content

Commit d3c4445

Browse files
tomaspozoclaude
andcommitted
refactor: rename Hono context variable from supabase to supabaseContext
Avoids naming clash with the supabase client inside SupabaseContext, following Hono conventions for descriptive variable names (jwtPayload, requestId, etc.). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 10725e3 commit d3c4445

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/adapters/hono/middleware.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { describe, expect, it } from 'vitest'
44
import type { SupabaseContext } from '../../types.js'
55
import { supabase } from './middleware.js'
66

7-
type Env = { Variables: { supabase: SupabaseContext } }
7+
type Env = { Variables: { supabaseContext: SupabaseContext } }
88

99
describe('hono supabase middleware', () => {
1010
const env = {
@@ -18,7 +18,7 @@ describe('hono supabase middleware', () => {
1818
const app = new Hono<Env>()
1919
app.use('*', supabase({ allow: 'always', env }))
2020
app.get('/', (c) => {
21-
const ctx = c.get('supabase')
21+
const ctx = c.get('supabaseContext')
2222
return c.json({
2323
authType: ctx.authType,
2424
hasSupabase: !!ctx.supabase,

src/adapters/hono/middleware.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import type { SupabaseContext, WithSupabaseConfig } from '../../types.js'
66

77
export function supabase(config?: Omit<WithSupabaseConfig, 'cors'>) {
88
return createMiddleware<{
9-
Variables: { supabase: SupabaseContext }
9+
Variables: { supabaseContext: SupabaseContext }
1010
}>(async (c, next) => {
1111
// Skip if a previous middleware already set the context.
1212
// This allows route-level overrides: a route can use supabase({ allow: 'secret' })
1313
// while the app-wide middleware uses supabase({ allow: 'user' }), without the
1414
// app-wide one overwriting the stricter context already established.
15-
if (c.var.supabase) {
15+
if (c.var.supabaseContext) {
1616
await next()
1717
return
1818
}
@@ -25,7 +25,7 @@ export function supabase(config?: Omit<WithSupabaseConfig, 'cors'>) {
2525
})
2626
}
2727

28-
c.set('supabase', ctx)
28+
c.set('supabaseContext', ctx)
2929
await next()
3030
})
3131
}

0 commit comments

Comments
 (0)