-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7f62cf1
commit 54f0ef9
Showing
25 changed files
with
598 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import type { FC } from 'react'; | ||
|
||
import ResultsGlobe from '@/components/ResultsGlobe'; | ||
|
||
export const runtime = 'edge'; | ||
|
||
const regions: Record<string, { name: string; lat: number; lng: number }> = { | ||
arn1: { lat: 59.652222, lng: 17.918611, name: 'Stockholm, Sweden' }, | ||
bom1: { lat: 19.088744, lng: 72.867905, name: 'Mumbai, India' }, | ||
cdg1: { lat: 49.009691, lng: 2.547925, name: 'Paris, France' }, | ||
cle1: { lat: 41.405772, lng: -81.849769, name: 'Cleveland, USA' }, | ||
cpt1: { lat: -33.964806, lng: 18.601667, name: 'Cape Town, South Africa' }, | ||
dub1: { lat: 53.421333, lng: -6.270075, name: 'Dublin, Ireland' }, | ||
fra1: { lat: 50.033333, lng: 8.570556, name: 'Frankfurt, Germany' }, | ||
gru1: { lat: -23.435556, lng: -46.473056, name: 'São Paulo, Brazil' }, | ||
hkg1: { lat: 22.308046, lng: 113.91848, name: 'Hong Kong, China' }, | ||
hnd1: { lat: 35.553333, lng: 139.781111, name: 'Tokyo, Japan' }, | ||
iad1: { lat: 38.944, lng: -77.456, name: 'Dulles, USA' }, | ||
icn1: { lat: 37.4625, lng: 126.439167, name: 'Seoul, South Korea' }, | ||
kix1: { lat: 34.434167, lng: 135.232778, name: 'Osaka, Japan' }, | ||
lhr1: { lat: 51.477, lng: -0.461, name: 'London, UK' }, | ||
pdx1: { lat: 45.5875, lng: -122.593333, name: 'Portland, USA' }, | ||
sfo1: { lat: 37.618056, lng: -122.378611, name: 'San Francisco, USA' }, | ||
sin1: { lat: 1.356944, lng: 103.988611, name: 'Singapore, Singapore' }, | ||
syd1: { lat: -33.946111, lng: 151.177222, name: 'Sydney, Australia' }, | ||
}; | ||
|
||
type MapResultsPageProps = { | ||
params: { | ||
domain: string; | ||
}; | ||
}; | ||
|
||
const MapResultsPage: FC<MapResultsPageProps> = async ({ | ||
params: { domain }, | ||
}) => { | ||
const markers = await Promise.all( | ||
Object.entries(regions).map(async ([code, data]) => { | ||
const response = await fetch( | ||
`${ | ||
process.env.SITE_URL || | ||
process.env.VERCEL_URL || | ||
'http://localhost:3000' | ||
}/lookup/${domain}/map/resolve/${code}?type=A&domain=${domain}` | ||
); | ||
if (!response.ok) | ||
throw new Error(`Failed to fetch ${code}, ${await response.text()}`); | ||
const results = await response.json(); | ||
|
||
return { | ||
...data, | ||
results: { | ||
A: results as string[], | ||
}, | ||
}; | ||
}) | ||
); | ||
|
||
return <ResultsGlobe markers={markers} />; | ||
}; | ||
|
||
export default MapResultsPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { handler } from '../base'; | ||
|
||
export const runtime = 'edge'; | ||
export const preferredRegion = 'arn1'; | ||
|
||
export const GET = handler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
export const handler = async (request: Request) => { | ||
const { searchParams } = new URL(request.url); | ||
const type = searchParams.get('type'); | ||
const domain = searchParams.get('domain'); | ||
|
||
if (!type || !domain) { | ||
return Response.json( | ||
{ | ||
error: true, | ||
message: '"type" and "domain" params are required', | ||
}, | ||
{ | ||
status: 400, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
} | ||
); | ||
} | ||
|
||
const response = await fetch( | ||
`https://cloudflare-dns.com/dns-query?name=${domain}&type=${type}`, | ||
{ | ||
headers: { Accept: 'application/dns-json' }, | ||
} | ||
); | ||
const results = await response.json(); | ||
|
||
return Response.json(results.Answer.map((a: { data: string }) => a.data)); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { handler } from '../base'; | ||
|
||
export const runtime = 'edge'; | ||
export const preferredRegion = 'bom1'; | ||
|
||
export const GET = handler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { handler } from '../base'; | ||
|
||
export const runtime = 'edge'; | ||
export const preferredRegion = 'cdg1'; | ||
|
||
export const GET = handler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { handler } from '../base'; | ||
|
||
export const runtime = 'edge'; | ||
export const preferredRegion = 'cle1'; | ||
|
||
export const GET = handler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { handler } from '../base'; | ||
|
||
export const runtime = 'edge'; | ||
export const preferredRegion = 'cpt1'; | ||
|
||
export const GET = handler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { handler } from '../base'; | ||
|
||
export const runtime = 'edge'; | ||
export const preferredRegion = 'dub1'; | ||
|
||
export const GET = handler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { handler } from '../base'; | ||
|
||
export const runtime = 'edge'; | ||
export const preferredRegion = 'fra1'; | ||
|
||
export const GET = handler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { handler } from '../base'; | ||
|
||
export const runtime = 'edge'; | ||
export const preferredRegion = 'gru1'; | ||
|
||
export const GET = handler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { handler } from '../base'; | ||
|
||
export const runtime = 'edge'; | ||
export const preferredRegion = 'hkg1'; | ||
|
||
export const GET = handler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { handler } from '../base'; | ||
|
||
export const runtime = 'edge'; | ||
export const preferredRegion = 'hnd1'; | ||
|
||
export const GET = handler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { handler } from '../base'; | ||
|
||
export const runtime = 'edge'; | ||
export const preferredRegion = 'iad1'; | ||
|
||
export const GET = handler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { handler } from '../base'; | ||
|
||
export const runtime = 'edge'; | ||
export const preferredRegion = 'icn1'; | ||
|
||
export const GET = handler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { handler } from '../base'; | ||
|
||
export const runtime = 'edge'; | ||
export const preferredRegion = 'kix1'; | ||
|
||
export const GET = handler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { handler } from '../base'; | ||
|
||
export const runtime = 'edge'; | ||
export const preferredRegion = 'lhr1'; | ||
|
||
export const GET = handler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { handler } from '../base'; | ||
|
||
export const runtime = 'edge'; | ||
export const preferredRegion = 'pdx1'; | ||
|
||
export const GET = handler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { handler } from '../base'; | ||
|
||
export const runtime = 'edge'; | ||
export const preferredRegion = 'sfo1'; | ||
|
||
export const GET = handler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { handler } from '../base'; | ||
|
||
export const runtime = 'edge'; | ||
export const preferredRegion = 'sin1'; | ||
|
||
export const GET = handler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { handler } from '../base'; | ||
|
||
export const runtime = 'edge'; | ||
export const preferredRegion = 'syd1'; | ||
|
||
export const GET = handler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
'use client'; | ||
|
||
import type { FC } from 'react'; | ||
import Globe from 'react-globe.gl'; | ||
|
||
export const runtime = 'edge'; | ||
|
||
type ResultsGlobeProps = { | ||
markers: { | ||
name: string; | ||
lat: number; | ||
lng: number; | ||
results: { | ||
A: string[]; | ||
}; | ||
}[]; | ||
}; | ||
|
||
const ResultsGlobe: FC<ResultsGlobeProps> = ({ markers }) => ( | ||
<Globe | ||
// Map from https://github.com/vasturiano/three-globe/blob/7717c8e54c98dcb3e92df5a95923f51387a496a1/example/img/earth-day.jpg | ||
globeImageUrl="/assets/earth-day.jpg" | ||
backgroundColor="rgba(0,0,0,0)" | ||
htmlElementsData={markers} | ||
// @ts-expect-error | ||
htmlElement={(d: ResultsGlobeProps['markers'][number]) => { | ||
const el = document.createElement('div'); | ||
el.innerHTML = `<div class="relative bg-white p-2 rounded-lg shadow-md"> | ||
<h3 class="text-sm font-bold mb-2">${d.name}</h3> | ||
${d.results.A.map( | ||
(ip) => `<p class="text-xs text-gray-500">${ip}</p>` | ||
).join('')} | ||
</div>`; | ||
return el; | ||
}} | ||
/> | ||
); | ||
|
||
export default ResultsGlobe; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.