feat: update backend services and routes
- Add business routes and middleware\n- Update search and database services\n- Improve health check implementation\n- Update CI workflow configuration
This commit is contained in:
parent
79f26fce25
commit
9f4ae1baac
15 changed files with 1501 additions and 1348 deletions
|
|
@ -2,41 +2,34 @@ import { createClient } from '@supabase/supabase-js';
|
|||
import { env } from '../config/env';
|
||||
|
||||
// Validate Supabase configuration
|
||||
if (!env.supabase.url || !env.supabase.anonKey) {
|
||||
if (!env.SUPABASE_URL || !env.SUPABASE_KEY) {
|
||||
throw new Error('Missing Supabase configuration');
|
||||
}
|
||||
|
||||
// Create Supabase client
|
||||
export const supabase = createClient(
|
||||
env.supabase.url,
|
||||
env.supabase.anonKey,
|
||||
env.SUPABASE_URL,
|
||||
env.SUPABASE_KEY,
|
||||
{
|
||||
auth: {
|
||||
autoRefreshToken: true,
|
||||
persistSession: true
|
||||
persistSession: true,
|
||||
detectSessionInUrl: true
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// Test the connection on startup
|
||||
async function testConnection() {
|
||||
// Test connection function
|
||||
export async function testConnection() {
|
||||
try {
|
||||
console.log('Checking Supabase connection...');
|
||||
console.log('URL:', env.supabase.url);
|
||||
|
||||
const { error } = await supabase
|
||||
.from('businesses')
|
||||
.select('count', { count: 'planned', head: true });
|
||||
|
||||
if (error) {
|
||||
console.error('❌ Supabase initialization error:', error);
|
||||
} else {
|
||||
console.log('✅ Supabase connection initialized successfully');
|
||||
}
|
||||
console.log('Testing Supabase connection...');
|
||||
console.log('URL:', env.SUPABASE_URL);
|
||||
const { data, error } = await supabase.from('searches').select('count');
|
||||
if (error) throw error;
|
||||
console.log('Supabase connection successful');
|
||||
return true;
|
||||
} catch (error) {
|
||||
console.error('❌ Failed to initialize Supabase:', error);
|
||||
console.error('Supabase connection failed:', error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Run the test
|
||||
testConnection().catch(console.error);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue