fix: security hardening and performance improvements

Security:
- Add token+secret auth to /setup-webhook and /webhook-info endpoints
- Disable /api/test in production environment (ENVIRONMENT=production)

Performance:
- Add retryWithBackoff to weather-tool (maxRetries: 2)
- Add KV caching to executeLookupDocs (1h TTL)

Code Quality:
- Centralize error messages in src/constants/messages.ts
- Update 5 files to use centralized error constants

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
kappa
2026-01-21 17:35:51 +09:00
parent 91f50ddc12
commit dab279c765
12 changed files with 121 additions and 27 deletions

View File

@@ -8,6 +8,7 @@ import type {
import { retryWithBackoff, RetryError } from '../utils/retry';
import { createLogger, maskUserId } from '../utils/logger';
import { getOpenAIUrl } from '../utils/api-urls';
import { ERROR_MESSAGES } from '../constants/messages';
const logger = createLogger('domain-tool');
@@ -405,7 +406,7 @@ async function callNamecheapApi(
} catch (error) {
logger.error('오류', error as Error, { domain: funcArgs.domain });
if (error instanceof RetryError) {
return { error: 'WHOIS 조회 서비스에 일시적으로 접근할 수 없습니다.' };
return { error: ERROR_MESSAGES.WHOIS_SERVICE_UNAVAILABLE };
}
return { error: `WHOIS 조회 오류: ${String(error)}` };
}
@@ -1063,7 +1064,7 @@ ${excludeList ? `- 다음 도메인은 제외하세요: ${excludeList}` : ''}
} catch (error) {
logger.error('오류', error as Error, { keywords });
if (error instanceof RetryError) {
return `🚫 도메인 추천 서비스에 일시적으로 접근할 수 없습니다. 잠시 후 다시 시도해주세요.`;
return ERROR_MESSAGES.DOMAIN_SERVICE_UNAVAILABLE;
}
return `🚫 도메인 추천 중 오류가 발생했습니다: ${String(error)}`;
}