// Simple test script for Hyperdrive configuration // This script helps verify the wrangler.toml configuration console.log('šŸš€ Hyperdrive NeonDB Test Configuration'); console.log('====================================='); // Check if wrangler.toml exists and has correct configuration const fs = require('fs'); const path = require('path'); try { const wranglerPath = path.join(__dirname, 'wrangler.toml'); if (fs.existsSync(wranglerPath)) { console.log('āœ… wrangler.toml found'); const content = fs.readFileSync(wranglerPath, 'utf8'); // Check for Hyperdrive configuration if (content.includes('hyperdrive')) { console.log('āœ… Hyperdrive configuration found'); } else { console.log('āŒ Hyperdrive configuration missing'); } // Check for binding if (content.includes('binding = "HYPERDRIVE"')) { console.log('āœ… HYPERDRIVE binding configured'); } else { console.log('āŒ HYPERDRIVE binding missing'); } // Check for Hyperdrive ID if (content.includes('ef43924d89064cddabfaccf06aadfab6')) { console.log('āœ… Hyperdrive ID configured'); } else { console.log('āŒ Hyperdrive ID missing'); } // Check for nodejs_compat if (content.includes('nodejs_compat')) { console.log('āœ… nodejs_compat flag enabled'); } else { console.log('āŒ nodejs_compat flag missing'); } } else { console.log('āŒ wrangler.toml not found'); } // Check if src/index.ts exists const indexPath = path.join(__dirname, 'src', 'index.ts'); if (fs.existsSync(indexPath)) { console.log('āœ… src/index.ts found'); } else { console.log('āŒ src/index.ts missing'); } // Check if package.json exists const packagePath = path.join(__dirname, 'package.json'); if (fs.existsSync(packagePath)) { console.log('āœ… package.json found'); const packageContent = JSON.parse(fs.readFileSync(packagePath, 'utf8')); // Check for required dependencies if (packageContent.dependencies && packageContent.dependencies.pg) { console.log('āœ… pg dependency configured'); } else { console.log('āŒ pg dependency missing'); } if (packageContent.devDependencies && packageContent.devDependencies['@cloudflare/workers-types']) { console.log('āœ… Cloudflare Workers types configured'); } else { console.log('āŒ Cloudflare Workers types missing'); } } console.log('\nšŸ“‹ Next Steps:'); console.log('1. Run: wrangler dev --local (for local testing)'); console.log('2. Run: wrangler dev (for remote testing with Hyperdrive)'); console.log('3. Test endpoints:'); console.log(' - http://localhost:8787/test-connection'); console.log(' - http://localhost:8787/test-query'); console.log('\nšŸ”§ Hyperdrive Configuration:'); console.log(' - Hyperdrive ID: ef43924d89064cddabfaccf06aadfab6'); console.log(' - Binding: HYPERDRIVE'); console.log(' - Database: NeonDB (PostgreSQL)'); } catch (error) { console.error('āŒ Error checking configuration:', error.message); }