feat: 대역폭 추정 및 DAU 표시 기능 추가
- 동시접속자 기반 월간 대역폭 자동 추정 - DAU(일일활성사용자) 추정치 표시 (동접 × 10-14) - 대역폭 기반 Linode/Vultr 자동 선택 로직 - 비용 분석에 대역폭 비용 포함 - 지역 미선택시 서울/도쿄/오사카/싱가포르 기본 표시 - 지역별 서버 분리 표시 (GROUP BY instance + region) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
1799
src/index.ts
Normal file
1799
src/index.ts
Normal file
File diff suppressed because it is too large
Load Diff
92
src/types.ts
Normal file
92
src/types.ts
Normal file
@@ -0,0 +1,92 @@
|
||||
/**
|
||||
* Type definitions for Server Recommendation API
|
||||
*/
|
||||
|
||||
/**
|
||||
* Server requirements provided by user
|
||||
*/
|
||||
export interface ServerRequirements {
|
||||
cpu: string; // e.g., "4 cores", "8 vCPU"
|
||||
memory: string; // e.g., "16GB", "32GB RAM"
|
||||
storage: string; // e.g., "500GB SSD", "1TB NVMe"
|
||||
network: string; // e.g., "1Gbps", "10Gbps unmetered"
|
||||
availability: string; // e.g., "99.9%", "enterprise SLA"
|
||||
budget: string; // e.g., "$100/month", "under $200"
|
||||
}
|
||||
|
||||
/**
|
||||
* Server recommendation returned by AI
|
||||
*/
|
||||
export interface ServerRecommendation {
|
||||
provider: string; // Hosting provider name
|
||||
plan: string; // Specific plan/product name
|
||||
cpu: string; // CPU specifications
|
||||
memory: string; // RAM specifications
|
||||
storage: string; // Storage specifications
|
||||
network: string; // Network specifications
|
||||
price: string; // Monthly cost
|
||||
availability: string; // SLA or uptime guarantee
|
||||
reason: string; // Why this server was recommended
|
||||
matchScore: number; // Match score (0-100)
|
||||
}
|
||||
|
||||
/**
|
||||
* API request body for recommendations
|
||||
*/
|
||||
export interface RecommendationRequest {
|
||||
requirements: ServerRequirements;
|
||||
}
|
||||
|
||||
/**
|
||||
* API response for recommendations
|
||||
*/
|
||||
export interface RecommendationResponse {
|
||||
recommendations: ServerRecommendation[];
|
||||
cached: boolean;
|
||||
timestamp: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Error response structure
|
||||
*/
|
||||
export interface ErrorResponse {
|
||||
error: string;
|
||||
message: string;
|
||||
timestamp: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cloudflare Worker environment bindings
|
||||
*/
|
||||
export interface Env {
|
||||
AI: Ai; // Workers AI binding
|
||||
DB: D1Database; // D1 database binding
|
||||
CACHE?: KVNamespace; // KV namespace binding (optional)
|
||||
}
|
||||
|
||||
/**
|
||||
* D1 database row for server catalog
|
||||
*/
|
||||
export interface ServerCatalogRow {
|
||||
id: number;
|
||||
provider: string;
|
||||
plan: string;
|
||||
cpu: string;
|
||||
memory: string;
|
||||
storage: string;
|
||||
network: string;
|
||||
price: string;
|
||||
availability: string;
|
||||
features: string; // JSON string of additional features
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cache entry structure
|
||||
*/
|
||||
export interface CacheEntry {
|
||||
recommendations: ServerRecommendation[];
|
||||
timestamp: string;
|
||||
ttl: number;
|
||||
}
|
||||
Reference in New Issue
Block a user