mirror of
https://github.com/koala73/worldmonitor.git
synced 2026-04-25 17:14:57 +02:00
- Add variant system (full/tech) with VITE_VARIANT env var - Create tech-geo.ts with 465 entries: - 295 TECH_HQS (FAANG, unicorns across US, Europe, MENA, India, SEA, China, LATAM, Africa) - 112 ACCELERATORS (YC, Techstars, 500 Global, regional accelerators) - 38 STARTUP_HUBS (mega/major/emerging tiers) - 20 CLOUD_REGIONS (AWS, GCP, Azure, Cloudflare) - Add map layers: startupHubs, cloudRegions, accelerators, techHQs - Add tech-specific RSS feeds and panels - Fix YouTube channel fallback IDs (Yahoo Finance, NASA TV, TBPN) - MENA expansion: 50+ companies (UAE, Saudi, Egypt, Jordan) - India: 40+ unicorns (Flipkart, PhonePe, Razorpay, etc) - SEA: 25+ companies (Grab, GoTo, J&T Express, etc) - LATAM: 35+ companies (Nubank, MercadoLibre, Bitso, etc)
85 lines
2.6 KiB
JavaScript
85 lines
2.6 KiB
JavaScript
export const config = { runtime: 'edge' };
|
|
|
|
// Fetch trending GitHub repositories
|
|
// Uses unofficial GitHub trending scraper API
|
|
export default async function handler(request) {
|
|
try {
|
|
const { searchParams } = new URL(request.url);
|
|
const language = searchParams.get('language') || 'python'; // python, javascript, typescript, etc.
|
|
const since = searchParams.get('since') || 'daily'; // daily, weekly, monthly
|
|
const spoken_language = searchParams.get('spoken_language') || ''; // en, zh, etc.
|
|
|
|
// Using GitHub trending API (unofficial)
|
|
// Alternative: https://gh-trending-api.herokuapp.com/repositories
|
|
const baseUrl = 'https://api.gitterapp.com/repositories';
|
|
const queryParams = new URLSearchParams({
|
|
language: language,
|
|
since: since,
|
|
});
|
|
|
|
if (spoken_language) {
|
|
queryParams.append('spoken_language_code', spoken_language);
|
|
}
|
|
|
|
const apiUrl = `${baseUrl}?${queryParams.toString()}`;
|
|
|
|
const response = await fetch(apiUrl, {
|
|
headers: {
|
|
'Accept': 'application/json',
|
|
'User-Agent': 'WorldMonitor/1.0 (Tech Tracker)',
|
|
},
|
|
signal: AbortSignal.timeout(10000), // 10 second timeout
|
|
});
|
|
|
|
if (!response.ok) {
|
|
// Fallback: try alternative API
|
|
const fallbackUrl = `https://gh-trending-api.herokuapp.com/repositories/${language}?since=${since}`;
|
|
const fallbackResponse = await fetch(fallbackUrl, {
|
|
headers: {
|
|
'Accept': 'application/json',
|
|
},
|
|
signal: AbortSignal.timeout(10000),
|
|
});
|
|
|
|
if (!fallbackResponse.ok) {
|
|
throw new Error(`GitHub trending API returned ${fallbackResponse.status}`);
|
|
}
|
|
|
|
const data = await fallbackResponse.json();
|
|
return new Response(JSON.stringify(data), {
|
|
status: 200,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'Access-Control-Allow-Origin': '*',
|
|
'Cache-Control': 'public, max-age=1800', // 30 min cache
|
|
},
|
|
});
|
|
}
|
|
|
|
const data = await response.json();
|
|
|
|
return new Response(JSON.stringify(data), {
|
|
status: 200,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'Access-Control-Allow-Origin': '*',
|
|
'Cache-Control': 'public, max-age=1800', // 30 min cache
|
|
},
|
|
});
|
|
} catch (error) {
|
|
return new Response(
|
|
JSON.stringify({
|
|
error: 'Failed to fetch GitHub trending data',
|
|
message: error.message
|
|
}),
|
|
{
|
|
status: 500,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'Access-Control-Allow-Origin': '*'
|
|
},
|
|
}
|
|
);
|
|
}
|
|
}
|