1// Test script for Moniker API integration
2// Run with: node scripts/test_moniker.js
4require('dotenv').config({ path: require('path').resolve(__dirname, '../.env') });
5const moniker = require('../services/moniker');
10async function testMonikerAPI() {
11 console.log('๐งช Testing Moniker API Integration\n');
12 console.log('='.repeat(50));
15 // Test 1: Check if example.com is available
16 console.log('\n๐ Test 1: Checking domain availability');
17 console.log('-'.repeat(50));
19 const domain = 'example.com';
20 console.log(`Checking: ${domain}`);
22 const result = await moniker.checkDomain(domain);
23 console.log('โ
Result:', JSON.stringify(result, null, 2));
25 // Test 2: Check multiple domains
26 console.log('\n๐ Test 2: Checking multiple domains');
27 console.log('-'.repeat(50));
29 const domains = ['test123456789.com', 'anothertestdomain123.com'];
30 console.log(`Checking: ${domains.join(', ')}`);
32 const results = await moniker.checkDomains(domains);
33 console.log('โ
Results:', JSON.stringify(results, null, 2));
35 console.log('\n' + '='.repeat(50));
36 console.log('โ
All tests passed!');
37 console.log('๐ Moniker API integration is working correctly');
40 console.error('\nโ Test failed:', error.message);
42 console.error('Response data:', error.response.data);
50 console.log('\nโจ Test complete');
54 console.error('\n๐ฅ Unexpected error:', err);