const http = require('http');

function get(path) {
  return new Promise((resolve, reject) => {
    http.get(`http://localhost:3000${path}`, (res) => {
      let data = '';
      res.on('data', chunk => data += chunk);
      res.on('end', () => {
        try {
          console.log(`\n${path}`);
          console.log('Status:', res.statusCode);
          console.log('Response:', JSON.stringify(JSON.parse(data), null, 2).substring(0, 500));
          resolve(JSON.parse(data));
        } catch (e) {
          console.error('Parse error:', e.message);
          reject(e);
        }
      });
    }).on('error', reject);
  });
}

async function main() {
  console.log('检查 API 返回格式...\n');
  
  try {
    await get('/api/history?page=1&pageSize=2');
    await get('/api/tts/voices');
  } catch (e) {
    console.error('Error:', e.message);
  }
}

main();
