refactor: code quality improvements (P3)
## Type Safety
- Add zod runtime validation for external API responses
* Namecheap API responses (domain-register.ts)
* n8n webhook responses (n8n-service.ts)
* User request bodies (routes/api.ts)
* Replaced unsafe type assertions with safeParse()
* Proper error handling and logging
## Dead Code Removal
- Remove unused callDepositAgent function (127 lines)
* Legacy Assistants API code no longer needed
* Now using direct code execution
* File reduced from 469 → 345 lines (26.4% reduction)
## Configuration Management
- Extract hardcoded URLs to environment variables
* Added 7 new vars in wrangler.toml:
OPENAI_API_BASE, NAMECHEAP_API_URL, WHOIS_API_URL,
CONTEXT7_API_BASE, BRAVE_API_BASE, WTTR_IN_URL, HOSTING_SITE_URL
* Updated Env interface in types.ts
* All URLs have fallback to current production values
* Enables environment-specific configuration (dev/staging/prod)
## Dependencies
- Add zod 4.3.5 for runtime type validation
## Files Modified
- Configuration: wrangler.toml, types.ts, package.json
- Services: 11 TypeScript files with URL/validation updates
- Total: 15 files, +196/-189 lines
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -12,6 +12,15 @@ N8N_WEBHOOK_URL = "https://n8n.anvil.it.com" # n8n 연동 (선택)
|
||||
DOMAIN_OWNER_ID = "821596605" # 도메인 관리 권한 Telegram ID
|
||||
DEPOSIT_ADMIN_ID = "821596605" # 예치금 관리 권한 Telegram ID
|
||||
|
||||
# API Endpoints
|
||||
OPENAI_API_BASE = "https://gateway.ai.cloudflare.com/v1/d8e5997eb4040f8b489f09095c0f623c/telegram-bot/openai"
|
||||
NAMECHEAP_API_URL = "https://namecheap-api.anvil.it.com"
|
||||
WHOIS_API_URL = "https://whois-api-kappa-inoutercoms-projects.vercel.app"
|
||||
CONTEXT7_API_BASE = "https://context7.com/api/v2"
|
||||
BRAVE_API_BASE = "https://api.search.brave.com/res/v1"
|
||||
WTTR_IN_URL = "https://wttr.in"
|
||||
HOSTING_SITE_URL = "https://hosting.anvil.it.com"
|
||||
|
||||
[[d1_databases]]
|
||||
binding = "DB"
|
||||
database_name = "telegram-conversations"
|
||||
|
||||
Reference in New Issue
Block a user