Migrate from Supabase to Appwrite with core functionality and UI components
This commit is contained in:
45
src/lib/appwrite/config.ts
Normal file
45
src/lib/appwrite/config.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* Appwrite 설정
|
||||
*
|
||||
* 이 파일은 Appwrite 서비스에 필요한 모든 설정 값을 정의합니다.
|
||||
* 환경 변수에서 값을 가져오며, 기본값을 제공합니다.
|
||||
*/
|
||||
|
||||
// Appwrite 설정 타입 정의
|
||||
export interface AppwriteConfig {
|
||||
endpoint: string;
|
||||
projectId: string;
|
||||
databaseId: string;
|
||||
transactionsCollectionId: string;
|
||||
}
|
||||
|
||||
// 환경 변수에서 설정 값 가져오기
|
||||
const endpoint = import.meta.env.VITE_APPWRITE_ENDPOINT || 'https://a11.ism.kr/v1';
|
||||
const projectId = import.meta.env.VITE_APPWRITE_PROJECT_ID || 'zellyy-finance';
|
||||
const databaseId = import.meta.env.VITE_APPWRITE_DATABASE_ID || 'zellyy-finance';
|
||||
const transactionsCollectionId = import.meta.env.VITE_APPWRITE_TRANSACTIONS_COLLECTION_ID || 'transactions';
|
||||
|
||||
// 설정 객체 생성
|
||||
export const config: AppwriteConfig = {
|
||||
endpoint,
|
||||
projectId,
|
||||
databaseId,
|
||||
transactionsCollectionId
|
||||
};
|
||||
|
||||
/**
|
||||
* 서버 연결 유효성 검사
|
||||
* @returns 유효한 설정인지 여부
|
||||
*/
|
||||
export const isValidAppwriteConfig = (): boolean => {
|
||||
return Boolean(endpoint && projectId);
|
||||
};
|
||||
|
||||
/**
|
||||
* 설정 값 검증 및 오류 발생
|
||||
* @throws 필수 설정이 없는 경우 오류 발생
|
||||
*/
|
||||
export const validateConfig = (): void => {
|
||||
if (!endpoint) throw new Error("VITE_APPWRITE_ENDPOINT is not set");
|
||||
if (!projectId) throw new Error("VITE_APPWRITE_PROJECT_ID is not set");
|
||||
};
|
||||
Reference in New Issue
Block a user