// Test script to validate Hyperdrive configuration for remote deployment // This script helps test the configuration without local PostgreSQL const { execSync } = require('child_process'); const fs = require('fs'); console.log('šŸš€ Testing Hyperdrive Configuration for Remote Deployment'); console.log('======================================================'); try { // Check wrangler configuration console.log('\nšŸ“‹ Validating wrangler.toml...'); const wranglerContent = fs.readFileSync('wrangler.toml', 'utf8'); console.log('āœ… wrangler.toml loaded successfully'); // Validate configuration syntax try { execSync('wrangler config validate', { stdio: 'pipe' }); console.log('āœ… wrangler.toml syntax is valid'); } catch (error) { console.log('āš ļø Configuration validation warning (this is normal for Hyperdrive)'); } // Check if we can authenticate with Cloudflare console.log('\nšŸ” Checking Cloudflare authentication...'); try { const whoami = execSync('wrangler whoami', { encoding: 'utf8' }); console.log('āœ… Authenticated with Cloudflare'); console.log(` ${whoami.trim()}`); } catch (error) { console.log('āŒ Not authenticated with Cloudflare'); console.log(' Run: wrangler login'); return; } // List Hyperdrive configurations console.log('\nšŸ”— Checking Hyperdrive configurations...'); try { const hyperdrives = execSync('wrangler hyperdrive list', { encoding: 'utf8' }); console.log('āœ… Hyperdrive configurations:'); console.log(hyperdrives); } catch (error) { console.log('āš ļø Could not list Hyperdrive configurations'); console.log(' Error:', error.message); } // Check specific Hyperdrive console.log('\nšŸŽÆ Checking specific Hyperdrive ID...'); try { const hyperdriveInfo = execSync('wrangler hyperdrive get ef43924d89064cddabfaccf06aadfab6', { encoding: 'utf8' }); console.log('āœ… Hyperdrive configuration found:'); console.log(hyperdriveInfo); } catch (error) { console.log('āŒ Could not find Hyperdrive configuration'); console.log(' Error:', error.message); console.log(' Make sure the Hyperdrive ID is correct and exists in your account'); } console.log('\nšŸ“ Configuration Summary:'); console.log(' - Worker Name: hyperdrive-neondb-test'); console.log(' - Hyperdrive ID: ef43924d89064cddabfaccf06aadfab6'); console.log(' - Binding: HYPERDRIVE'); console.log(' - Database Type: NeonDB (PostgreSQL)'); console.log('\nšŸš€ Deployment Commands:'); console.log(' 1. Deploy to production: wrangler deploy'); console.log(' 2. Test endpoints after deployment:'); console.log(' - https://hyperdrive-neondb-test..workers.dev/test-connection'); console.log(' - https://hyperdrive-neondb-test..workers.dev/test-query'); console.log('\nšŸ’” Tips:'); console.log(' - Hyperdrive provides connection pooling and caching for your database'); console.log(' - It reduces latency and improves performance for database queries'); console.log(' - The worker will automatically use the Hyperdrive connection in production'); } catch (error) { console.error('āŒ Error during testing:', error.message); }