Files
xget/api/health.js
T
xixu-me 1480595fbc Add Kaggle platform support and path transformation
Introduces Kaggle as a supported platform in the configuration and health check. Implements special path transformation logic for Kaggle API endpoints in transformPath, and adds comprehensive tests to verify correct path handling for various Kaggle API routes.
2025-08-20 22:17:48 +08:00

80 lines
1.9 KiB
JavaScript

/**
* Vercel Edge Function for health checks and service information
* Accessible at /api/health
*/
export default async function handler(request) {
const url = new URL(request.url);
// Basic service information
const serviceInfo = {
service: 'Xget',
version: '1.0.0',
platform: 'Vercel Edge Functions',
status: 'OK',
timestamp: new Date().toISOString(),
uptime: process.uptime ? Math.floor(process.uptime()) : 'N/A',
regions: ['iad1', 'hnd1', 'fra1', 'sfo1'],
endpoints: {
health: '/api/health',
root: '/',
proxy: '/{platform}/{path}'
},
supported_platforms: [
'GitHub (gh)',
'GitLab (gl)',
'Gitea',
'Codeberg',
'SourceForge (sf)',
'Hugging Face (hf)',
'npm',
'PyPI',
'conda',
'Maven',
'Apache',
'Gradle',
'Homebrew',
'RubyGems',
'CRAN',
'CPAN',
'CTAN',
'Go modules',
'NuGet',
'Rust crates',
'Packagist',
'Container Registries',
'AI Inference Providers',
'arXiv',
'F-Droid',
'Kaggle'
]
};
// Add request information for debugging
if (url.searchParams.get('debug') === 'true') {
serviceInfo.request_info = {
method: request.method,
url: request.url,
headers: Object.fromEntries(request.headers.entries()),
cf: request.cf || 'Not available on Vercel',
user_agent: request.headers.get('User-Agent'),
ip: request.headers.get('x-forwarded-for') || request.headers.get('x-real-ip') || 'Unknown'
};
}
return new Response(JSON.stringify(serviceInfo, null, 2), {
status: 200,
headers: {
'Content-Type': 'application/json',
'Cache-Control': 'public, max-age=60',
'X-Service': 'Xget-Vercel',
'X-Powered-By': 'Vercel Edge Functions'
}
});
}
export const config = {
runtime: 'edge',
regions: ['iad1', 'hnd1', 'fra1', 'sfo1']
};