- Add shared buildFlexibleRegionConditions() in utils.ts
- Add COUNTRY_NAME_TO_REGIONS mapping for country/city expansion
- Update servers.ts to use flexible region matching (korea, tokyo, japan, etc.)
- Update recommend.ts to use shared function (remove duplicate code)
- Fix servers GROUP BY to show all regions (it.id, r.id)
- Update CLAUDE.md with single-line curl examples
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Apply sanitizeForAIPrompt to AI prompt (prevent prompt injection)
- Replace hardcoded provider IDs with name-based filtering
- Remove dead code (queryVPSBenchmarks function)
- Use LIMITS.MAX_REQUEST_BODY_BYTES constant
- Change parseAIResponse parameter from `any` to `unknown`
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1. hashString 함수 수정
- Math.abs() → >>> 0 unsigned 변환
2. CSP 보안 헤더 추가
- Content-Security-Policy: default-src 'none'
3. 캐시 키 충돌 방지
- URL-safe base64 인코딩으로 변경
4. CORS 보안 강화
- Origin 없는 요청에 빈 문자열 반환 (CORS 미적용)
- 허용 목록 기반 Origin 검증
5. estimateBandwidth 리팩토링
- USE_CASE_CONFIGS 활용으로 중복 정규식 제거
- switch 문으로 가독성 향상
- getDauMultiplier, getActiveUserRatio 간소화
6. 요청 본문 크기 제한
- 10KB 초과 요청 차단 (413 응답)
- 대용량 payload 공격 방어
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1. CONFIG 상수 추출
- Rate limit, Currency, Bandwidth, AI, Cache 설정 중앙화
- 매직 넘버 10개 → CONFIG 참조로 변경
2. 미사용 함수 제거
- queryVPSBenchmarks 함수 삭제 (52줄)
3. 에러 타입 체크 개선
- catch 블록에서 unknown 타입 사용
- err.message 접근 전 instanceof 체크
4. 쿼리 병렬화
- queryCandidateServers + queryVPSBenchmarksBatch 병렬 실행
- 예상 15-25% 응답 시간 개선
5. Use Case 패턴 통합
- USE_CASE_CONFIGS로 중복 제거
- getDauMultiplier, getActiveUserRatio 간소화
- 50줄 이상 중복 코드 제거
6. DB 성능 인덱스 추가
- instance_types(provider_id, vcpu, memory_mb)
- pricing(instance_type_id, region_id)
- regions(region_code, country_code)
- vps_benchmarks 관련 인덱스
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1. SQL injection 취약점 수정 (currency 직접 삽입 제거)
- SQL 쿼리에서 currency 제거, 결과 매핑에서 추가
2. 에러 메시지 정보 노출 수정
- 클라이언트에 내부 에러 상세 숨김
- 서버 로그에만 기록
3. API 키 로깅 제거
- sk-*** 형식만 표시, 실제 값 노출 안함
4. Rate limit fail-closed 정책 적용
- KV 오류 시 요청 거부 (보안 강화)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- AI_GATEWAY_URL 환경변수로 AI Gateway 활성화
- OpenAI 지역 차단(HKG 등) 우회 가능
- 403 에러 시 지역 차단 감지 및 안내 메시지 추가
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
## vCPU 계산 로직 개선
- 카테고리 합산 → 병목 분석(Max)으로 변경
- nginx+nodejs+postgresql 조합: 16 vCPU → 10 vCPU
- 요청 흐름(web→app→db)에서 가장 느린 컴포넌트가 병목
## 메모리 계산 로직 개선
- memory_intensive 서비스: Max → 합산으로 변경
- java+elasticsearch+redis: 8GB → 11GB (실제 동시 실행 반영)
## 대역폭 추정 개선
- 사용자 활동률(activeUserRatio) 추가
- video: 30%, gaming: 50%, e-commerce: 40%
- 비디오 1000명: 257TB → ~80TB/월 (현실적)
## DAU 변환 비율 개선
- 용도별 차등 적용 (getDauMultiplier)
- gaming: 10-20배, blog: 30-50배, saas: 5-10배
## aliases 대소문자 수정
- LOWER(aliases) LIKE로 case-insensitive 매칭
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- DB 결과 타입 검증용 type guard 함수 추가 (isValidServer, isValidVPSBenchmark, isValidTechSpec, isValidBenchmarkData, isValidAIRecommendation)
- 모든 DB 쿼리 결과에 타입 가드 적용하여 런타임 검증
- AI 응답 파싱에 구조 검증 추가
- OpenAI API 호출에 30초 타임아웃 추가 (AbortController)
- 타임아웃 에러 처리 개선
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- minVcpu: expected_users / vcpu_per_users 기반 최소 vCPU 필터링
- 대역폭 기반 provider 필터링:
- very_heavy (>6TB/month): Linode만 표시
- heavy (2-6TB/month): Linode 우선 정렬
- queryCandidateServers에 minVcpu, bandwidthEstimate 파라미터 추가
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- 동시접속자 기반 월간 대역폭 자동 추정
- DAU(일일활성사용자) 추정치 표시 (동접 × 10-14)
- 대역폭 기반 Linode/Vultr 자동 선택 로직
- 비용 분석에 대역폭 비용 포함
- 지역 미선택시 서울/도쿄/오사카/싱가포르 기본 표시
- 지역별 서버 분리 표시 (GROUP BY instance + region)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>