Skip to content

Commit

Permalink
Add Whois quick info 👀
Browse files Browse the repository at this point in the history
  • Loading branch information
wotschofsky committed Nov 5, 2023
1 parent 88de8e4 commit 4761c9f
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 5 deletions.
25 changes: 25 additions & 0 deletions app/error.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use client';

import { type FC, useEffect } from 'react';

type GlobalErrorProps = {
error: Error & { digest?: string };
reset: () => void;
};

const GlobalError: FC<GlobalErrorProps> = ({ error }) => {
useEffect(() => {
console.error(error);
}, [error]);

return (
<div className="mt-12 flex flex-col items-center gap-2">
<h2>Something went VERY wrong!</h2>
<p className="mt-2 text-center text-sm text-muted-foreground">
Digest: {error.digest}
</p>
</div>
);
};

export default GlobalError;
4 changes: 0 additions & 4 deletions app/lookup/[domain]/certs/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ type CertsResultsPageProps = {
};
};

export const runtime = 'edge';
// crt.sh located in GB, always use LHR1 for lowest latency
export const preferredRegion = 'lhr1';

const CertsResultsPage: FC<CertsResultsPageProps> = async ({
params: { domain },
}) => {
Expand Down
9 changes: 8 additions & 1 deletion app/lookup/[domain]/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { ExternalLinkIcon } from 'lucide-react';
import type { Metadata } from 'next';
import type { FC, ReactNode } from 'react';
import { type FC, type ReactNode, Suspense } from 'react';

import RelatedDomains from '@/components/RelatedDomains';
import ResultsTabs from '@/components/ResultsTabs';
import SearchForm from '@/components/SearchForm';
import WhoisQuickInfo, {
WhoisQuickInfoPlaceholder,
} from '@/components/WhoisQuickInfo';

type LookupLayoutProps = {
children: ReactNode;
Expand Down Expand Up @@ -54,6 +57,10 @@ const LookupLayout: FC<LookupLayoutProps> = ({
</h1>

<RelatedDomains domain={domain} />
<Suspense fallback={<WhoisQuickInfoPlaceholder />}>
{/* TODO Add error boundary */}
<WhoisQuickInfo domain={domain} />
</Suspense>
<ResultsTabs domain={domain} />

{children}
Expand Down
68 changes: 68 additions & 0 deletions components/WhoisQuickInfo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { FC } from 'react';
import whoiser, { type WhoisSearchResult } from 'whoiser';

import { Skeleton } from './ui/skeleton';

type WhoisQuickInfoProps = {
domain: string;
};

const WhoisQuickInfo: FC<WhoisQuickInfoProps> = async ({ domain }) => {
const results = await whoiser(domain, {
timeout: 5000,
});
const firstResult = results[
// @ts-expect-error
Object.keys(results).filter((key) => !('error' in results[key]))[0]
] as WhoisSearchResult;

return (
<div className="my-8 flex gap-8">
<div>
<h3 className="text-xs text-muted-foreground">Registrar</h3>
<p className="text-sm">
{firstResult && 'Registrar' in firstResult
? firstResult['Registrar'].toString()
: 'Unavailable'}
</p>
</div>
<div>
<h3 className="text-xs text-muted-foreground">Creation Date</h3>
<p className="text-sm">
{firstResult && 'Created Date' in firstResult
? new Date(
firstResult['Created Date'].toString()
).toLocaleDateString('en-US')
: 'Unavailable'}
</p>
</div>
<div>
<h3 className="text-xs text-muted-foreground">DNSSEC</h3>
<p className="text-sm">
{firstResult && 'DNSSEC' in firstResult
? firstResult['DNSSEC'].toString()
: 'Unavailable'}
</p>
</div>
</div>
);
};

export default WhoisQuickInfo;

export const WhoisQuickInfoPlaceholder: FC = () => (
<div className="my-8 flex gap-8">
<div>
<h3 className="text-xs text-muted-foreground">Registrar</h3>
<Skeleton className="mt-1 h-4 w-24 rounded-sm" />
</div>
<div>
<h3 className="text-xs text-muted-foreground">Creation Date</h3>
<Skeleton className="w-18 mt-1 h-4 rounded-sm" />
</div>
<div>
<h3 className="text-xs text-muted-foreground">DNSSEC</h3>
<Skeleton className="mt-1 h-4 w-16 rounded-sm" />
</div>
</div>
);

1 comment on commit 4761c9f

@vercel
Copy link

@vercel vercel bot commented on 4761c9f Nov 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

domain-digger – ./

domain-digger-wotschofsky.vercel.app
domain-digger-git-main-wotschofsky.vercel.app
digger.tools
www.digger.tools

Please sign in to comment.