refactor: cleanup temp files, centralize API URL, and dynamic routing
- 불필요한 마이그레이션 스크립트, JSON 덤프, 백업 폴더 일괄 삭제 - 프론트엔드 API_BASE_URL 상수 도입 및 하드코딩된 API 엔드포인트 통합 - 백엔드(server.js) GET/POST 라우팅 구조를 Map 기반 동적 라우팅으로 리팩토링 - 미사용 dummyDataGenerator 제거
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { HardwareAsset, SoftwareAsset, SWUser, HardwareLog } from './excelHandler';
|
||||
import { API_BASE_URL } from './utils';
|
||||
|
||||
// --- State Definitions ---
|
||||
export interface MasterAssetData {
|
||||
@@ -79,8 +80,7 @@ export async function loadMasterDataFromDB() {
|
||||
{ key: 'logs', url: '/api/asset/history' }
|
||||
];
|
||||
|
||||
const host = `http://${location.hostname}:3000`;
|
||||
const results = await Promise.all(endpoints.map(e => fetch(host + e.url)));
|
||||
const results = await Promise.all(endpoints.map(e => fetch(API_BASE_URL + e.url)));
|
||||
|
||||
for (let i = 0; i < endpoints.length; i++) {
|
||||
if (results[i].ok) {
|
||||
@@ -148,7 +148,7 @@ export async function saveAsset(category: string, asset: any) {
|
||||
'vip': '/api/vip/batch'
|
||||
};
|
||||
|
||||
const url = `http://${location.hostname}:3000${endpointMap[category]}`;
|
||||
const url = `${API_BASE_URL}${endpointMap[category]}`;
|
||||
const currentList = [...(state.masterData as any)[category]];
|
||||
const idx = currentList.findIndex(a => a.id === asset.id);
|
||||
|
||||
@@ -194,7 +194,7 @@ export async function deleteAsset(category: string, assetId: string) {
|
||||
'vip': '/api/vip/batch'
|
||||
};
|
||||
|
||||
const url = `http://${location.hostname}:3000${endpointMap[category]}`;
|
||||
const url = `${API_BASE_URL}${endpointMap[category]}`;
|
||||
const currentList = [...(state.masterData as any)[category]];
|
||||
const filteredList = currentList.filter(a => a.id !== assetId);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user