// Ultra-minimal Node.js app - NO dependencies at all
// If this fails, it's a fundamental Passenger/Node.js issue

const http = require('http');

const server = http.createServer((req, res) => {
  res.writeHead(200, {'Content-Type': 'text/html'});
  res.end(`
    <!DOCTYPE html>
    <html>
    <head><title>CompareKit Ultra-Minimal Test</title></head>
    <body style="font-family: Arial; padding: 40px; background: #f0f0f0;">
      <h1 style="color: green;">✅ SUCCESS!</h1>
      <h2>Node.js is working!</h2>
      <p><strong>Node.js version:</strong> ${process.version}</p>
      <p><strong>Process ID:</strong> ${process.pid}</p>
      <p><strong>Current directory:</strong> ${process.cwd()}</p>
      <p><strong>Environment:</strong> ${process.env.NODE_ENV || 'not set'}</p>
      <hr>
      <p>This test uses ZERO npm packages - just core Node.js HTTP module.</p>
      <p>If you see this, the problem is with package dependencies or NPM install.</p>
    </body>
    </html>
  `);
});

// For Passenger, it handles the port
module.exports = server;

// For standalone testing
if (typeof(PhusionPassenger) === 'undefined') {
  const PORT = process.env.PORT || 3000;
  server.listen(PORT, () => {
    console.log('Ultra-minimal test server running on port ' + PORT);
  });
}
