Monorepo for Aesthetic.Computer aesthetic.computer
at main 242 lines 8.3 kB view raw
1#!/usr/bin/env node 2 3/** 4 * Short Domain Availability Checker for QR Code Optimization 5 * 6 * Goal: Find the shortest possible domain to minimize QR code size. 7 * 8 * QR Code Version vs Character Capacity (Alphanumeric, Error Level L): 9 * - Version 1 (21×21): 25 chars 10 * - Version 2 (25×25): 47 chars <- Current with prompt.ac 11 * - Version 3 (29×29): 77 chars 12 * 13 * URL format: https://DOMAIN/CODE 14 * - "https://" = 8 chars 15 * - "/" = 1 char 16 * - CODE = variable (let's assume 8-12 chars for typical codes) 17 * 18 * To fit in Version 1 (21×21), we need: domain + 8 + 1 + code ≤ 25 19 * With 10-char code: domain ≤ 6 chars (e.g., "q.ac" = 4 chars) 20 */ 21 22// List of short, potentially cheap TLDs that work well for short domains 23const SHORT_TLDS = [ 24 // 2-letter ccTLDs (often cheap) 25 'ac', // Ascension Island - ~$26/yr 26 'ai', // Anguilla - expensive ($70+) 27 'cc', // Cocos Islands - ~$12/yr 28 'co', // Colombia - ~$30/yr 29 'cx', // Christmas Island - ~$25/yr 30 'gg', // Guernsey - ~$70/yr 31 'gs', // South Georgia - ~$40/yr 32 'im', // Isle of Man - ~$20/yr 33 'io', // British Indian Ocean - ~$40/yr (popular for tech) 34 'is', // Iceland - ~$60/yr 35 'la', // Laos - ~$40/yr 36 'li', // Liechtenstein - ~$30/yr 37 'ly', // Libya - ~$100/yr 38 'me', // Montenegro - ~$15/yr 39 'mn', // Mongolia - ~$50/yr 40 'mu', // Mauritius - ~$90/yr 41 'ms', // Montserrat - ~$35/yr 42 'nu', // Niue - ~$25/yr 43 'sh', // Saint Helena - ~$60/yr 44 'so', // Somalia - ~$80/yr 45 'tc', // Turks and Caicos - ~$100/yr 46 'tl', // Timor-Leste - ~$100/yr 47 'to', // Tonga - ~$70/yr 48 'tv', // Tuvalu - ~$35/yr 49 'vc', // St Vincent - ~$40/yr 50 'vg', // British Virgin Islands - ~$40/yr 51 'ws', // Samoa - ~$30/yr 52 53 // New gTLDs (often cheap promos) 54 'lol', // ~$30/yr 55 'wtf', // ~$30/yr 56 'xyz', // ~$1/yr first year! 57 'fun', // ~$20/yr 58 'one', // ~$10/yr 59 'app', // ~$15/yr (requires HTTPS) 60 'dev', // ~$15/yr (requires HTTPS) 61 'page', // ~$10/yr 62 'link', // ~$12/yr 63 'click', // ~$10/yr 64 'site', // ~$3/yr 65 'online', // ~$5/yr 66 'run', // ~$20/yr 67 'zip', // ~$15/yr (but confusing with file extension) 68]; 69 70// Single letter domains to check (most are taken but worth checking) 71const SINGLE_LETTERS = 'abcdefghijklmnopqrstuvwxyz0123456789'.split(''); 72 73// Two letter combinations to check 74const TWO_LETTER_PREFIXES = ['qr', 'ac', 'go', 'do', 'my', 'io', 'hi', 'ok', 'up', 'it']; 75 76async function checkDomainWhois(domain) { 77 // Using DNS lookup as a quick availability proxy 78 // Note: This doesn't guarantee availability, just checks if it resolves 79 try { 80 const { promises: dns } = await import('dns'); 81 await dns.resolve(domain); 82 return { domain, status: 'taken', note: 'Resolves to IP' }; 83 } catch (err) { 84 if (err.code === 'ENOTFOUND' || err.code === 'ENODATA') { 85 return { domain, status: 'possibly-available', note: 'No DNS records' }; 86 } 87 return { domain, status: 'unknown', note: err.code }; 88 } 89} 90 91async function checkDomainRDAP(domain) { 92 // Try RDAP lookup for more accurate availability check 93 const tld = domain.split('.').pop(); 94 const rdapServers = { 95 'ac': 'https://rdap.nic.ac/domain/', 96 'io': 'https://rdap.nic.io/domain/', 97 'co': 'https://rdap.nic.co/domain/', 98 'me': 'https://rdap.nic.me/domain/', 99 'xyz': 'https://rdap.centralnic.com/xyz/domain/', 100 // Add more as needed 101 }; 102 103 const rdapUrl = rdapServers[tld]; 104 if (!rdapUrl) return null; 105 106 try { 107 const response = await fetch(rdapUrl + domain, { 108 headers: { 'Accept': 'application/rdap+json' } 109 }); 110 if (response.status === 404) { 111 return { domain, status: 'available', note: 'RDAP: Not found' }; 112 } else if (response.ok) { 113 const data = await response.json(); 114 return { domain, status: 'taken', note: `RDAP: Registered` }; 115 } 116 return null; 117 } catch (err) { 118 return null; 119 } 120} 121 122function calculateQRVersion(url) { 123 // Rough estimate of QR version needed for alphanumeric URL 124 const len = url.length; 125 if (len <= 25) return { version: 1, size: '21×21' }; 126 if (len <= 47) return { version: 2, size: '25×25' }; 127 if (len <= 77) return { version: 3, size: '29×29' }; 128 if (len <= 114) return { version: 4, size: '33×33' }; 129 return { version: '5+', size: '37×37+' }; 130} 131 132async function main() { 133 console.log('🔍 Short Domain Availability Checker for QR Optimization\n'); 134 console.log('=' .repeat(60)); 135 136 // Calculate current situation 137 const currentDomain = 'prompt.ac'; 138 const exampleCode = 'TESTCODE'; 139 const currentUrl = `https://${currentDomain}/${exampleCode}`; 140 const currentQR = calculateQRVersion(currentUrl); 141 142 console.log(`\n📊 Current Setup:`); 143 console.log(` Domain: ${currentDomain}`); 144 console.log(` Example URL: ${currentUrl} (${currentUrl.length} chars)`); 145 console.log(` QR Version: ${currentQR.version} (${currentQR.size})`); 146 147 console.log(`\n🎯 Goal: Find shorter domain to achieve Version 1 (21×21) QR code`); 148 console.log(` Need total URL ≤ 25 chars`); 149 console.log(` With "https://" (8) + "/" (1) + code (10) = 19 chars`); 150 console.log(` Domain must be ≤ 6 chars (e.g., "q.ac" = 4 chars)\n`); 151 152 console.log('=' .repeat(60)); 153 console.log('\n🔎 Checking potential short domains...\n'); 154 155 // Priority domains to check (shortest that might work) 156 const priorityDomains = []; 157 158 // 1-letter.2-letter-tld domains (shortest possible) 159 for (const letter of SINGLE_LETTERS.slice(0, 10)) { // Check first 10 letters 160 for (const tld of ['ac', 'co', 'io', 'me', 'cc']) { // Cheapest short TLDs 161 priorityDomains.push(`${letter}.${tld}`); 162 } 163 } 164 165 // 2-letter.2-letter-tld domains 166 for (const prefix of TWO_LETTER_PREFIXES) { 167 for (const tld of ['ac', 'co', 'io', 'me']) { 168 priorityDomains.push(`${prefix}.${tld}`); 169 } 170 } 171 172 // Check domains 173 const results = []; 174 let checked = 0; 175 176 for (const domain of priorityDomains.slice(0, 30)) { // Limit to 30 for speed 177 const url = `https://${domain}/${exampleCode}`; 178 const qr = calculateQRVersion(url); 179 180 // Quick DNS check 181 const dnsResult = await checkDomainWhois(domain); 182 183 results.push({ 184 domain, 185 urlLength: url.length, 186 qrVersion: qr.version, 187 qrSize: qr.size, 188 status: dnsResult.status, 189 note: dnsResult.note 190 }); 191 192 checked++; 193 process.stdout.write(`\r Checked ${checked}/${Math.min(priorityDomains.length, 30)} domains...`); 194 } 195 196 console.log('\n'); 197 198 // Display results 199 console.log('📋 Results (sorted by URL length):\n'); 200 console.log('Domain'.padEnd(12) + 'URL Len'.padEnd(10) + 'QR Ver'.padEnd(8) + 'QR Size'.padEnd(10) + 'Status'); 201 console.log('-'.repeat(60)); 202 203 results 204 .sort((a, b) => a.urlLength - b.urlLength) 205 .forEach(r => { 206 const statusIcon = r.status === 'possibly-available' ? '🟢' : 207 r.status === 'taken' ? '🔴' : '⚪'; 208 console.log( 209 r.domain.padEnd(12) + 210 String(r.urlLength).padEnd(10) + 211 String(r.qrVersion).padEnd(8) + 212 r.qrSize.padEnd(10) + 213 `${statusIcon} ${r.status}` 214 ); 215 }); 216 217 // Find potential winners 218 const available = results.filter(r => r.status === 'possibly-available' && r.qrVersion === 1); 219 220 console.log('\n' + '=' .repeat(60)); 221 222 if (available.length > 0) { 223 console.log('\n🎉 Potentially available domains that could achieve Version 1 QR:'); 224 available.forEach(r => console.log(` ${r.domain}${r.qrSize} QR code!`)); 225 } else { 226 console.log('\n⚠️ No available single-letter domains found (they\'re usually premium)'); 227 } 228 229 console.log('\n💡 Recommendations:'); 230 console.log(' 1. Single-letter .ac domains (a.ac, q.ac) are usually $1000+/yr premium'); 231 console.log(' 2. Two-letter domains (qr.ac, ac.co) might be available for ~$30-50/yr'); 232 console.log(' 3. Consider URL shortener services (bit.ly, t.co) as alternative'); 233 console.log(' 4. Your current prompt.ac is actually quite good!'); 234 235 console.log('\n🔗 Check availability and pricing:'); 236 console.log(' - https://www.namecheap.com/domains/registration/'); 237 console.log(' - https://www.porkbun.com/products/domains'); 238 console.log(' - https://tld-list.com/ (price comparison)'); 239 console.log(' - https://spaceship.com/ (often cheapest)\n'); 240} 241 242main().catch(console.error);