-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-connection.js
More file actions
57 lines (45 loc) · 1.42 KB
/
test-connection.js
File metadata and controls
57 lines (45 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Simple test to check Supabase connection
// Add this to your browser console to test
import { supabase } from './src/lib/supabaseClient.js';
async function testConnection() {
console.log('Testing Supabase connection...');
try {
// Test 1: Check if we can connect to Supabase
const { data, error } = await supabase
.from('users')
.select('count', { count: 'exact' });
if (error) {
console.error('❌ Connection error:', error);
return false;
}
console.log('✅ Connected to Supabase successfully');
console.log('Users table count:', data);
// Test 2: Try to insert a test user
const testUsername = 'test_' + Math.random().toString(36).substr(2, 9);
const { data: insertData, error: insertError } = await supabase
.from('users')
.insert([{
username: testUsername,
password: 'testpass123'
}])
.select()
.single();
if (insertError) {
console.error('❌ Insert error:', insertError);
return false;
}
console.log('✅ Successfully inserted test user:', insertData);
// Clean up - delete the test user
await supabase
.from('users')
.delete()
.eq('id', insertData.id);
console.log('✅ Test completed successfully');
return true;
} catch (err) {
console.error('❌ Test failed:', err);
return false;
}
}
// Run the test
testConnection();