The SupabaseSettingsForm component was refactored into smaller, more manageable components to improve readability and maintainability.
56 lines
1.7 KiB
TypeScript
56 lines
1.7 KiB
TypeScript
|
|
import { testAuth } from './authTests';
|
|
import { testRestApi } from './apiTests';
|
|
import { testDatabaseConnection } from './databaseTests';
|
|
import { TestResults } from './types';
|
|
import { supabase, isValidUrl } from '../client';
|
|
import { getSupabaseUrl, getSupabaseKey, isCorsProxyEnabled, getProxyType } from '../config';
|
|
|
|
export const testSupabaseConnection = async (): Promise<TestResults> => {
|
|
// 기본 결과 객체 초기화
|
|
const results: TestResults = {
|
|
url: getSupabaseUrl(),
|
|
usingProxy: isCorsProxyEnabled(),
|
|
proxyType: getProxyType(),
|
|
client: true,
|
|
restApi: false,
|
|
auth: false,
|
|
database: false,
|
|
errors: []
|
|
};
|
|
|
|
try {
|
|
// 클라이언트 유효성 체크
|
|
if (!supabase) {
|
|
results.client = false;
|
|
results.errors.push('Supabase 클라이언트 초기화 실패');
|
|
return results;
|
|
}
|
|
|
|
// 테스트 실행
|
|
const authResults = await testAuth(supabase, results.url);
|
|
const apiResults = await testRestApi(supabase);
|
|
const dbResults = await testDatabaseConnection(supabase);
|
|
|
|
// 결과 업데이트
|
|
results.auth = authResults.success;
|
|
results.restApi = apiResults.success;
|
|
results.database = dbResults.success;
|
|
|
|
// 오류 수집
|
|
if (!authResults.success) {
|
|
results.errors.push(`인증 테스트 실패: ${authResults.error}`);
|
|
}
|
|
if (!apiResults.success) {
|
|
results.errors.push(`REST API 테스트 실패: ${apiResults.error}`);
|
|
}
|
|
if (!dbResults.success) {
|
|
results.errors.push(`DB 테스트 실패: ${dbResults.error}`);
|
|
}
|
|
} catch (error: any) {
|
|
results.errors.push(`테스트 실행 오류: ${error.message || '알 수 없는 오류'}`);
|
|
}
|
|
|
|
return results;
|
|
};
|