refactor: 파일 분리 리팩토링 (routes, services, tools, utils)
아키텍처 개선: - index.ts: 921줄 → 205줄 (77% 감소) - openai-service.ts: 1,356줄 → 148줄 (89% 감소) 새로운 디렉토리 구조: - src/routes/ - Webhook, API, Health check 핸들러 - webhook.ts (287줄) - api.ts (318줄) - health.ts (14줄) - src/services/ - 비즈니스 로직 - bank-sms-parser.ts (143줄) - deposit-matcher.ts (88줄) - src/tools/ - Function Calling 도구 모듈화 - weather-tool.ts (37줄) - search-tool.ts (156줄) - domain-tool.ts (725줄) - deposit-tool.ts (183줄) - utility-tools.ts (60줄) - index.ts (104줄) - 도구 레지스트리 - src/utils/ - 유틸리티 함수 - email-decoder.ts - Quoted-Printable 디코더 타입 에러 수정: - routes/webhook.ts: text undefined 체크 - summary-service.ts: D1 타입 캐스팅 - summary-service.ts: Workers AI 타입 처리 - n8n-service.ts: Workers AI 타입 + 미사용 변수 제거 빌드 검증: - TypeScript 타입 체크 통과 - Wrangler dev 로컬 빌드 성공 문서: - REFACTORING_SUMMARY.md 추가 - ROUTE_ARCHITECTURE.md 추가 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
37
src/tools/weather-tool.ts
Normal file
37
src/tools/weather-tool.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
// Weather Tool - wttr.in integration
|
||||
|
||||
export const weatherTool = {
|
||||
type: 'function',
|
||||
function: {
|
||||
name: 'get_weather',
|
||||
description: '특정 도시의 현재 날씨 정보를 가져옵니다',
|
||||
parameters: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
city: {
|
||||
type: 'string',
|
||||
description: '도시 이름 (예: Seoul, Tokyo, New York)',
|
||||
},
|
||||
},
|
||||
required: ['city'],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export async function executeWeather(args: { city: string }): Promise<string> {
|
||||
const city = args.city || 'Seoul';
|
||||
try {
|
||||
const response = await fetch(
|
||||
`https://wttr.in/${encodeURIComponent(city)}?format=j1`
|
||||
);
|
||||
const data = await response.json() as any;
|
||||
const current = data.current_condition[0];
|
||||
return `🌤 ${city} 날씨
|
||||
온도: ${current.temp_C}°C (체감 ${current.FeelsLikeC}°C)
|
||||
상태: ${current.weatherDesc[0].value}
|
||||
습도: ${current.humidity}%
|
||||
풍속: ${current.windspeedKmph} km/h`;
|
||||
} catch (error) {
|
||||
return `날씨 정보를 가져올 수 없습니다: ${city}`;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user