Major additions: - Territory manager system with application workflow - Custom pricing and page builder with Craft.js - Enhanced Stripe Connect onboarding - CodeReadr QR scanning integration - Kiosk mode for venue sales - Super admin dashboard and analytics - MCP integration for AI-powered operations Infrastructure improvements: - Centralized API client and routing system - Enhanced authentication with organization context - Comprehensive theme management system - Advanced event management with custom tabs - Performance monitoring and accessibility features Database schema updates: - Territory management tables - Custom pages and pricing structures - Kiosk PIN system - Enhanced organization profiles - CodeReadr integration tables 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
61 lines
1.7 KiB
TypeScript
61 lines
1.7 KiB
TypeScript
import { createServerClient, type CookieOptions } from '@supabase/ssr'
|
|
import type { Database } from './database.types'
|
|
import type { AstroCookies } from 'astro'
|
|
|
|
export function createSupabaseServerClient(
|
|
cookies: AstroCookies,
|
|
cookieOptions?: CookieOptions
|
|
) {
|
|
return createServerClient<Database>(
|
|
import.meta.env.PUBLIC_SUPABASE_URL!,
|
|
import.meta.env.PUBLIC_SUPABASE_ANON_KEY!,
|
|
{
|
|
cookies: {
|
|
get(name: string) {
|
|
return cookies.get(name)?.value
|
|
},
|
|
set(name: string, value: string, options: CookieOptions) {
|
|
cookies.set(name, value, options)
|
|
},
|
|
remove(name: string, options: CookieOptions) {
|
|
cookies.delete(name, options)
|
|
},
|
|
},
|
|
cookieOptions,
|
|
}
|
|
)
|
|
}
|
|
|
|
// Helper to create a client from Request headers (for API routes)
|
|
export function createSupabaseServerClientFromRequest(request: Request) {
|
|
const cookieHeader = request.headers.get('Cookie') || ''
|
|
|
|
return createServerClient<Database>(
|
|
import.meta.env.PUBLIC_SUPABASE_URL!,
|
|
import.meta.env.PUBLIC_SUPABASE_ANON_KEY!,
|
|
{
|
|
cookies: {
|
|
get(name: string) {
|
|
const cookies = parseCookies(cookieHeader)
|
|
return cookies[name]
|
|
},
|
|
set() {
|
|
// Can't set cookies in request context
|
|
},
|
|
remove() {
|
|
// Can't remove cookies in request context
|
|
},
|
|
},
|
|
}
|
|
)
|
|
}
|
|
|
|
function parseCookies(cookieHeader: string): Record<string, string> {
|
|
return cookieHeader.split(';').reduce((acc, cookie) => {
|
|
const [key, value] = cookie.trim().split('=')
|
|
if (key && value) {
|
|
acc[key] = decodeURIComponent(value)
|
|
}
|
|
return acc
|
|
}, {} as Record<string, string>)
|
|
} |