import fetch from 'node-fetch'; interface NewsItem { id: string; title: string; content: string; imageUrl?: string; articleDate: string; url: string; source: string; primary_category_id?: number | null; categories?: Array<{ id: number; name: string; icon?: string; }>; createdAt: string; updatedAt: string; } async function testNewsAPI() { console.log('Testing news API with different limit values...'); const limits = [10, 20, 50, 100, 1000]; for (const limit of limits) { try { console.log(`\nTesting with limit=${limit}:`); const response = await fetch(`http://localhost:3000/api/news?limit=${limit}`); if (!response.ok) { console.error(`Error: ${response.status} ${response.statusText}`); continue; } const data = await response.json() as NewsItem[]; console.log(`Received ${data.length} news items`); // Print the first and last item titles if (data.length > 0) { console.log(`First item: "${data[0].title}"`); if (data.length > 1) { console.log(`Last item: "${data[data.length - 1].title}"`); } } } catch (error) { console.error(`Error testing with limit=${limit}:`, error instanceof Error ? error.message : String(error)); } } } testNewsAPI().catch(err => { console.error('Unhandled error:', err); process.exit(1); });