import http from 'node:http';

function makeRequest(path) {
  return new Promise((resolve, reject) => {
    const req = http.request(`http://localhost:5001${path}`, (res) => {
      let data = '';
      res.on('data', chunk => data += chunk);
      res.on('end', () => resolve(data));
    });
    req.on('error', reject);
    req.end();
  });
}

async function debugPaginationHTML() {
  const html = await makeRequest('/saas-admin?authKey=admin123&view=notifications&page=2');
  console.log('HTML snippet around "items":');
  const idx = html.indexOf('items');
  if (idx !== -1) {
    console.log(html.substring(idx - 100, idx + 100));
  } else {
    console.log('"items" text not found in HTML.');
    console.log('Searching for "Page":');
    const idx2 = html.indexOf('Page');
    console.log(idx2 !== -1 ? html.substring(idx2 - 50, idx2 + 150) : 'Page text not found.');
  }
}

debugPaginationHTML().catch(console.error);
