Skip to content

Commit

Permalink
migrate to next.js v15 (#393)
Browse files Browse the repository at this point in the history
  • Loading branch information
maaaathis authored Oct 28, 2024
1 parent 41efa55 commit cd8f054
Show file tree
Hide file tree
Showing 15 changed files with 13,047 additions and 7,450 deletions.
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/*
!.yarn/releases
!.yarn/plugins
!.yarn/sdks

# testing
/coverage
Expand Down
6 changes: 6 additions & 0 deletions .idea/GitLink.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

934 changes: 934 additions & 0 deletions .yarn/releases/yarn-4.5.1.cjs

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.5.1.cjs
4 changes: 2 additions & 2 deletions app/api/from/base64/[base64]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { cleanDomain } from '@/lib/domain';

export async function GET(
request: Request,
context: { params: { base64: string } }
context: { params: Promise<{ base64: string }> }
) {
const base64 = context.params.base64;
const { base64 } = await context.params;

if (!base64) {
return NextResponse.json(
Expand Down
14 changes: 8 additions & 6 deletions app/lookup/[domain]/(overview)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ import DomainNotRegistered from '../../../../components/DomainNotRegistered';
export const fetchCache = 'default-no-store';

interface LookupDomainProps {
params: {
params: Promise<{
domain: string;
};
}>;
}

export const generateMetadata = ({
params: { domain },
}: LookupDomainProps): Metadata => {
export const generateMetadata = async ({
params: params,
}: LookupDomainProps): Promise<Metadata> => {
const { domain } = await params;
return {
openGraph: {
url: `/lookup/${domain}`,
Expand All @@ -39,8 +40,9 @@ export const generateMetadata = ({
};

const LookupDomain: FC<LookupDomainProps> = async ({
params: { domain },
params: params,
}): Promise<ReactElement> => {
const { domain } = await params;
const baseDomain = getDomain(domain);
const publicSuffix = getPublicSuffix(domain);

Expand Down
37 changes: 20 additions & 17 deletions app/lookup/[domain]/certs/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ type CertsData = {
serial_number: string;
}[];

export const runtime = 'edge';
export const preferredRegion = 'lhr1';

export const generateMetadata = ({
params: { domain },
}: CertsResultsPageProps): Metadata => ({
openGraph: {
url: `/lookup/${domain}/certs`,
},
alternates: {
canonical: `/lookup/${domain}/certs`,
},
});
export const generateMetadata = async ({
params: params,
}: CertsResultsPageProps): Promise<Metadata> => {
const { domain } = await params;
return {
openGraph: {
url: `/lookup/${domain}/certs`,
},
alternates: {
canonical: `/lookup/${domain}/certs`,
},
};
};

const lookupCerts = async (domain: string): Promise<CertsData> => {
const response = await fetch(
Expand All @@ -71,15 +71,18 @@ const lookupCerts = async (domain: string): Promise<CertsData> => {
};

type CertsResultsPageProps = {
params: {
params: Promise<{
domain: string;
};
}>;
};

const CertsResultsPage: FC<CertsResultsPageProps> = async ({
params: { domain },
params: params,
}): Promise<ReactElement> => {
const userAgent = headers().get('user-agent');
const { domain } = await params;
const header = await headers();

const userAgent = header.get('user-agent');
const isBotRequest = !userAgent || isbot(userAgent);

if (isBotRequest) {
Expand Down
3 changes: 2 additions & 1 deletion app/lookup/[domain]/dns/_components/GeoDnsCheck.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ interface Props {
export const GeoDnsCheck: FC<Props> = async ({
domain,
}): Promise<ReactElement> => {
const userAgent = headers().get('user-agent');
const header = await headers();
const userAgent = header.get('user-agent');
const isBotRequest = !userAgent || isbot(userAgent);

if (isBotRequest) return <></>;
Expand Down
48 changes: 25 additions & 23 deletions app/lookup/[domain]/dns/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,27 @@ const getResolver = (
};

type LookupDomainProps = {
params: {
params: Promise<{
domain: string;
};
searchParams: {
}>;
searchParams: Promise<{
resolver?: string;
location?: string;
};
}>;
};

export const fetchCache = 'default-no-store';

export const generateMetadata = ({
params: { domain },
searchParams: { resolver, location },
}: LookupDomainProps): Metadata => {
const params = new URLSearchParams();
if (resolver) params.set('resolver', resolver);
if (location) params.set('location', location);
const search = params.size ? `?${params.toString()}` : '';
export const generateMetadata = async ({
params: params,
searchParams: searchParams,
}: LookupDomainProps): Promise<Metadata> => {
const { domain } = await params;
const { resolver, location } = await searchParams;
const URLsearchParams = new URLSearchParams();
if (resolver) URLsearchParams.set('resolver', resolver);
if (location) URLsearchParams.set('location', location);
const search = URLsearchParams.size ? `?${URLsearchParams.toString()}` : '';

return {
openGraph: {
Expand All @@ -77,17 +79,20 @@ export const generateMetadata = ({
};

const LookupDomain: FC<LookupDomainProps> = async ({
params: { domain },
searchParams: { resolver: resolverName, location: locationName },
params: params,
searchParams: searchParams,
}): Promise<ReactElement> => {
if (locationName && !resolverName) {
const { domain } = await params;
const { resolver: resolverData, location } = await searchParams;

if (location && !resolverData) {
return redirect(
`/lookup/${encodeURIComponent(domain)}/dns`,
RedirectType.replace
);
}

const resolver = getResolver(resolverName, locationName);
const resolver = getResolver(resolverData, location);
const records = await resolver.resolveAllRecords(domain);
const ipsInfo = await getIpsInfo(
records.A.map((r) => r.data).concat(records.AAAA.map((r) => r.data))
Expand All @@ -106,15 +111,12 @@ const LookupDomain: FC<LookupDomainProps> = async ({
<>
<div className="flex flex-col justify-between gap-4 sm:flex-row">
<div className="flex flex-col gap-4 sm:flex-row sm:gap-8">
<ResolverSelector initialValue={resolverName} />
<LocationSelector
initialValue={locationName}
disabled={!resolverName}
/>
<ResolverSelector initialValue={resolverData} />
<LocationSelector initialValue={location} disabled={!resolverData} />
</div>
<div className="flex flex-col gap-2 sm:gap-4 md:flex-row">
{resolverName === 'google' && <FlushGoogleDnsCacheButton />}
{resolverName === 'cloudflare' && <FlushCloudflareDnsCacheButton />}
{resolverData === 'google' && <FlushGoogleDnsCacheButton />}
{resolverData === 'cloudflare' && <FlushCloudflareDnsCacheButton />}
<DnsHistoryButton domain={domain} />
</div>
</div>
Expand Down
35 changes: 20 additions & 15 deletions app/lookup/[domain]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,31 @@ import SearchForm from '@/components/SearchForm';

type LookupLayoutProps = {
children: ReactNode;
params: {
params: Promise<{
domain: string;
};
}>;
};

export const generateMetadata = ({
params: { domain },
}: LookupLayoutProps): Metadata => ({
title: `Results for ${domain} · digga`,
openGraph: {
type: 'website',
title: `Results for ${domain} · digga`,
description: `Find DNS records, WHOIS data, SSL/TLS certificate history and more for ${domain}`,
},
});
export const generateMetadata = async ({
params: params,
}: LookupLayoutProps): Promise<Metadata> => {
const propParams = await params;

return {
title: `Results for ${propParams.domain} · digga`,
openGraph: {
type: 'website',
title: `Results for ${propParams.domain} · digga`,
description: `Find DNS records, WHOIS data, SSL/TLS certificate history and more for ${propParams.domain}`,
},
};
};

const LookupLayout: FC<LookupLayoutProps> = ({
const LookupLayout: FC<LookupLayoutProps> = async ({
children,
params: { domain },
}): ReactElement => {
params: params,
}): Promise<ReactElement> => {
const { domain } = await params;
if (!isValidDomain(domain)) {
return notFound();
}
Expand Down
5 changes: 3 additions & 2 deletions app/lookup/[domain]/opengraph-image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ const kanitRegularFontP = fetch(
export const handler = async ({
params,
}: {
params: { domain: string };
params: Promise<{ domain: string }>;
}): Promise<ImageResponse> => {
const { domain } = await params;
const [interRegularFont, interBoldFont, kanitRegularFont] = await Promise.all(
[interRegularFontP, interBoldFontP, kanitRegularFontP]
);
Expand Down Expand Up @@ -49,7 +50,7 @@ export const handler = async ({
digga
</span>
<span style={{ fontSize: 48, fontWeight: 700 }}>
Results for {params.domain}
Results for {domain}
</span>
<span
style={{
Expand Down
30 changes: 17 additions & 13 deletions app/lookup/[domain]/whois/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@ import whoiser, { type WhoisSearchResult } from 'whoiser';
import StyledError from '@/components/StyledError';
import { getBaseDomain, getTLD } from '@/lib/utils';

export const generateMetadata = ({
params: { domain },
}: WhoisResultsPageProps): Metadata => ({
openGraph: {
url: `/lookup/${domain}/whois`,
},
alternates: {
canonical: `/lookup/${domain}/whois`,
},
});
export const generateMetadata = async ({
params: params,
}: WhoisResultsPageProps): Promise<Metadata> => {
const { domain } = await params;
return {
openGraph: {
url: `/lookup/${domain}/whois`,
},
alternates: {
canonical: `/lookup/${domain}/whois`,
},
};
};

const lookupWhois = async (domain: string) => {
const result = await whoiser(domain, {
Expand All @@ -32,14 +35,15 @@ const lookupWhois = async (domain: string) => {
};

type WhoisResultsPageProps = {
params: {
params: Promise<{
domain: string;
};
}>;
};

const WhoisResultsPage: FC<WhoisResultsPageProps> = async ({
params: { domain },
params: params,
}): Promise<ReactElement> => {
const { domain } = await params;
const baseDomain = getBaseDomain(domain);
const data = await lookupWhois(baseDomain);

Expand Down
2 changes: 1 addition & 1 deletion next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
Loading

1 comment on commit cd8f054

@vercel
Copy link

@vercel vercel bot commented on cd8f054 Oct 28, 2024

Choose a reason for hiding this comment

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

Please sign in to comment.