const http = require('http');

// Test creating a customer
const customerData = JSON.stringify({
    name: "Test Customer",
    phone: "1234567890",
    email: "test@example.com"
});

const options = {
    hostname: 'localhost',
    port: 3000,
    path: '/api/customers',
    method: 'POST',
    headers: {
        'Content-Type': 'application/json',
        'Content-Length': Buffer.byteLength(customerData)
    }
};

const req = http.request(options, (res) => {
    let data = '';
    res.on('data', chunk => data += chunk);
    res.on('end', () => {
        console.log('Customer creation response:', data);
        
        // Test getting customers
        http.get('http://localhost:3000/api/customers', (res) => {
            let data = '';
            res.on('data', chunk => data += chunk);
            res.on('end', () => {
                console.log('Customers list:', data);
            });
        });
    });
});

req.on('error', (error) => {
    console.error('Error:', error);
});

req.write(customerData);
req.end();