Implement error handling and loading states for Appwrite integration

This commit is contained in:
hansoo
2025-05-05 15:41:19 +09:00
parent f83bb384af
commit 5305c98970
19 changed files with 1055 additions and 209 deletions

88
src/test-appwrite.ts Normal file
View File

@@ -0,0 +1,88 @@
/**
* Appwrite 연결 테스트 스크립트
*
* 이 파일은 Appwrite 서비스와의 연결을 테스트하기 위한 스크립트입니다.
* 개발 가이드라인에 따라 UI 스레드를 차단하지 않도록 비동기 처리와 오류 처리를 포함합니다.
*/
import { Client, Account } from 'appwrite';
// 설정 값 직접 지정
const endpoint = 'https://a11.ism.kr/v1';
const projectId = '68182a300039f6d700a6'; // 올바른 프로젝트 ID
const apiKey = 'standard_9672cc2d052d4fc56d9d28e75c6476ff1029d932b7d375dbb4bb0f705d741d8e6d9ae154929009e01c7168810884b6ee80e6bb564d3fe6439b8b142ed4a8d287546bb0bed2531c20188a7ecc36e6f9983abb1ab0022c1656cf2219d4c2799655c7baef00ae4861fe74186dbb421141d9e2332f2fad812975ae7b4b7f57527cea';
// 테스트 함수
async function testAppwriteConnection() {
console.log('Appwrite 연결 테스트 시작...');
console.log('설정 정보:', {
endpoint,
projectId,
apiKey: apiKey ? '설정됨' : '설정되지 않음'
});
try {
// Appwrite 클라이언트 생성
const client = new Client();
client
.setEndpoint(endpoint)
.setProject(projectId);
// 계정 서비스 초기화
const account = new Account(client);
// 연결 테스트 (익명 세션 생성 시도)
try {
console.log('익명 세션 생성 시도...');
const session = await account.createAnonymousSession();
console.log('익명 세션 생성 성공:', session.$id);
// 세션 정보 확인
try {
const user = await account.get();
console.log('사용자 정보 확인 성공:', user.$id);
} catch (userError) {
console.error('사용자 정보 확인 실패:', userError);
}
// 세션 삭제
try {
await account.deleteSession(session.$id);
console.log('세션 삭제 성공');
} catch (deleteError) {
console.error('세션 삭제 실패:', deleteError);
}
} catch (sessionError) {
console.error('익명 세션 생성 실패:', sessionError);
// 프로젝트 정보 확인 시도
try {
console.log('프로젝트 정보 확인 시도...');
// 프로젝트 정보는 API 키가 있어야 확인 가능
if (!apiKey) {
console.error('API 키가 없어 프로젝트 정보를 확인할 수 없습니다.');
} else {
console.log('API 키가 있지만 클라이언트에서는 사용할 수 없습니다.');
}
} catch (projectError) {
console.error('프로젝트 정보 확인 실패:', projectError);
}
}
} catch (error) {
console.error('Appwrite 클라이언트 생성 오류:', error);
}
console.log('Appwrite 연결 테스트 완료');
}
// 테스트 실행
testAppwriteConnection()
.then(() => {
console.log('테스트가 완료되었습니다.');
})
.catch((error) => {
console.error('테스트 중 예외 발생:', error);
});