23 lines
596 B
TypeScript
23 lines
596 B
TypeScript
// Run with npx ts-node scratch/test-geoip.ts
|
|
import { getGeoInfo } from '../lib/geo';
|
|
|
|
async function test() {
|
|
const testIps = [
|
|
'8.8.8.8', // Google (US)
|
|
'41.207.160.0', // Orange (CI)
|
|
'1.1.1.1', // Cloudflare (AU/US)
|
|
'102.64.170.0', // Maroc Telecom (MA)
|
|
'127.0.0.1' // Local
|
|
];
|
|
|
|
console.log('Testing GeoIP Detection...\n');
|
|
|
|
for (const ip of testIps) {
|
|
const mockHeaders = new Headers();
|
|
const result = await getGeoInfo(ip, mockHeaders);
|
|
console.log(`IP: ${ip.padEnd(15)} => Country: ${result.country.padEnd(20)} City: ${result.city}`);
|
|
}
|
|
}
|
|
|
|
test();
|