// Quick test to verify security routes are loaded
const http = require('http');

console.log('Testing if security routes are available on the running server...\n');

// Test health endpoint first
http.get('http://localhost:83/api/health', (res) => {
  console.log('✅ Backend server is running on port 83');
  console.log(`   Health endpoint status: ${res.statusCode}\n`);
  
  // Now test security endpoint
  http.get('http://localhost:83/api/security/overview', (res) => {
    let data = '';
    res.on('data', chunk => data += chunk);
    res.on('end', () => {
      if (res.statusCode === 404) {
        console.log('❌ Security routes NOT loaded (404 - Route not found)');
        console.log('   Response:', data);
        console.log('\n🔄 SOLUTION: You need to RESTART the backend server!');
        console.log('   1. Stop the backend server (Ctrl+C in the backend terminal)');
        console.log('   2. Start it again: npm start');
        console.log('   3. The security routes will then be loaded\n');
      } else if (res.statusCode === 401) {
        console.log('✅ Security routes ARE loaded!');
        console.log('   Got 401 Unauthorized (expected - needs auth token)');
        console.log('   The routes are working correctly!\n');
      } else {
        console.log(`⚠️  Got unexpected status: ${res.statusCode}`);
        console.log('   Response:', data);
      }
    });
  }).on('error', (err) => {
    console.log('❌ Could not connect to security endpoint');
    console.log('   Error:', err.message);
  });
}).on('error', (err) => {
  console.log('❌ Backend server is not running on port 83');
  console.log('   Error:', err.message);
  console.log('\n   Please start the backend server first: npm start');
});

