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.
60 lines
2.0 KiB
JavaScript
60 lines
2.0 KiB
JavaScript
import { getCorsHeaders, isDisallowedOrigin } from './_cors.js';
|
|
export const config = { runtime: 'edge' };
|
|
|
|
// Fetch AI/ML papers from ArXiv
|
|
// Categories: cs.AI, cs.LG (Machine Learning), cs.CL (Computation and Language)
|
|
export default async function handler(request) {
|
|
const cors = getCorsHeaders(request);
|
|
if (isDisallowedOrigin(request)) {
|
|
return new Response(JSON.stringify({ error: 'Origin not allowed' }), { status: 403, headers: cors });
|
|
}
|
|
try {
|
|
const { searchParams } = new URL(request.url);
|
|
const category = searchParams.get('category') || 'cs.AI'; // cs.AI, cs.LG, cs.CL
|
|
const maxResults = searchParams.get('max_results') || '50';
|
|
const sortBy = searchParams.get('sortBy') || 'submittedDate'; // submittedDate, lastUpdatedDate, relevance
|
|
|
|
// ArXiv API search query
|
|
// Search for papers in specified category, sorted by date
|
|
const query = `cat:${category}`;
|
|
const apiUrl = `https://export.arxiv.org/api/query?search_query=${encodeURIComponent(query)}&start=0&max_results=${maxResults}&sortBy=${sortBy}&sortOrder=descending`;
|
|
|
|
const response = await fetch(apiUrl, {
|
|
headers: {
|
|
'User-Agent': 'HanzoWorld/1.0 (AI Research Tracker)',
|
|
},
|
|
});
|
|
|
|
if (!response.ok) {
|
|
throw new Error(`ArXiv API returned ${response.status}`);
|
|
}
|
|
|
|
const xmlData = await response.text();
|
|
|
|
// Parse XML to extract key information
|
|
// Return raw XML for client-side parsing or transform here
|
|
return new Response(xmlData, {
|
|
status: 200,
|
|
headers: {
|
|
'Content-Type': 'application/xml',
|
|
...cors,
|
|
'Cache-Control': 'public, max-age=3600, s-maxage=3600, stale-while-revalidate=600', // 1 hour cache
|
|
},
|
|
});
|
|
} catch (error) {
|
|
return new Response(
|
|
JSON.stringify({
|
|
error: 'Failed to fetch ArXiv data',
|
|
message: error.message
|
|
}),
|
|
{
|
|
status: 500,
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
...cors
|
|
},
|
|
}
|
|
);
|
|
}
|
|
}
|