mirror of
https://github.com/hanzo-apps/world.git
synced 2026-10-30 14:53:09 +00:00
The fork still wore upstream's brand throughout: "World Monitor" in 754 places of prose and metadata, WORLD MONITOR in the blog logo and footer, and a byline reading "by Someone.ceo" — another company's name signing our pages. Blog assets, OG images and post directories were named for it too, and the OpenAPI schema types carried it in every identifier. Files are renamed, references follow them, and the localStorage and slug names match. Deleted .claudedocs/sentry-triage, an AI-written summary file of the kind that belongs in LLM.md if anywhere. NOTICE and LICENSE are untouched by design. NOTICE names the upstream project, the fork point and the original author; LICENSE keeps his copyright line, which MIT requires. That is where credit belongs — not in our product's chrome.
47 lines
1.6 KiB
JavaScript
47 lines
1.6 KiB
JavaScript
import { getCorsHeaders, isDisallowedOrigin } from '../../_cors.js';
|
|
export const config = { runtime: 'edge' };
|
|
|
|
export default async function handler(req) {
|
|
const cors = getCorsHeaders(req);
|
|
if (isDisallowedOrigin(req)) {
|
|
return new Response(JSON.stringify({ error: 'Origin not allowed' }), { status: 403, headers: cors });
|
|
}
|
|
const url = new URL(req.url);
|
|
const pairs = url.searchParams.get('pairs') || 'usa_russia,russia_ukraine,usa_china,china_taiwan,usa_iran,usa_venezuela';
|
|
const dateStart = url.searchParams.get('dateStart');
|
|
const dateEnd = url.searchParams.get('dateEnd');
|
|
const method = url.searchParams.get('method') || 'gpr';
|
|
|
|
let targetUrl = `https://www.pizzint.watch/api/gdelt/batch?pairs=${encodeURIComponent(pairs)}&method=${method}`;
|
|
if (dateStart) targetUrl += `&dateStart=${dateStart}`;
|
|
if (dateEnd) targetUrl += `&dateEnd=${dateEnd}`;
|
|
|
|
try {
|
|
const response = await fetch(targetUrl, {
|
|
headers: {
|
|
'Accept': 'application/json',
|
|
'User-Agent': 'HanzoWorld/1.0',
|
|
},
|
|
});
|
|
|
|
if (!response.ok) {
|
|
throw new Error(`Upstream returned ${response.status}`);
|
|
}
|
|
|
|
const data = await response.text();
|
|
return new Response(data, {
|
|
status: 200,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
...cors,
|
|
'Cache-Control': 'public, max-age=300, s-maxage=300, stale-while-revalidate=60',
|
|
},
|
|
});
|
|
} catch (error) {
|
|
return new Response(JSON.stringify({ error: 'Failed to fetch GDELT data', details: error.message }), {
|
|
status: 502,
|
|
headers: { 'Content-Type': 'application/json', ...cors },
|
|
});
|
|
}
|
|
}
|