Skip to content

Full Toolkit for Next-Level Domain Analysis

Move record type list 🏗️

Felix Wotschofskyb247bd52a93a
diff --git a/app/api/internal/resolve/base.ts b/app/api/internal/resolve/base.ts
index 227a8b4..b88454c 100644
--- a/app/api/internal/resolve/base.ts
+++ b/app/api/internal/resolve/base.ts
@@ -1,6 +1,7 @@
import { env } from '@/env';
+import { ALL_RECORD_TYPES } from '@/lib/data';
import { AlibabaDoHResolver } from '@/lib/resolvers/alibaba';
-import { ALL_RECORD_TYPES, type RecordType } from '@/lib/resolvers/base';
+import { type RecordType } from '@/lib/resolvers/base';
import { CloudflareDoHResolver } from '@/lib/resolvers/cloudflare';
import { GoogleDoHResolver } from '@/lib/resolvers/google';
@@ -63,8 +64,7 @@ export const handler = async (request: Request) => {
}
for (const type of types) {
- // @ts-expect-error
- if (!ALL_RECORD_TYPES.includes(type)) {
+ if (!ALL_RECORD_TYPES.includes(type as RecordType)) {
return Response.json(
{
error: true,
diff --git a/app/lookup/[domain]/(dns)/page.tsx b/app/lookup/[domain]/(dns)/page.tsx
index f978e52..83a4c88 100644
--- a/app/lookup/[domain]/(dns)/page.tsx
+++ b/app/lookup/[domain]/(dns)/page.tsx
@@ -2,8 +2,8 @@ import type { Metadata } from 'next';
import { redirect, RedirectType } from 'next/navigation';
import type { FC } from 'react';
+import { ALL_RECORD_TYPES } from '@/lib/data';
import { getRecordContextEntries } from '@/lib/record-context';
-import { ALL_RECORD_TYPES } from '@/lib/resolvers/base';
import { getResolverFromName } from '@/lib/resolvers/utils';
import { DnsTable } from './_components/dns-table';
diff --git a/lib/data.ts b/lib/data.ts
index ab89951..73f756c 100644
--- a/lib/data.ts
+++ b/lib/data.ts
@@ -36,6 +36,38 @@ export const EXAMPLE_DOMAINS = [
'discord.com',
];
+export const ALL_RECORD_TYPES = [
+ 'A',
+ 'AAAA',
+ 'CAA',
+ 'CNAME',
+ 'DNSKEY',
+ 'DS',
+ 'MX',
+ 'NAPTR',
+ 'NS',
+ 'PTR',
+ 'SOA',
+ 'SRV',
+ 'TXT',
+] as const;
+
+export const RECORD_TYPES_BY_DECIMAL = {
+ 1: 'A',
+ 28: 'AAAA',
+ 257: 'CAA',
+ 5: 'CNAME',
+ 48: 'DNSKEY',
+ 43: 'DS',
+ 15: 'MX',
+ 35: 'NAPTR',
+ 2: 'NS',
+ 12: 'PTR',
+ 6: 'SOA',
+ 33: 'SRV',
+ 16: 'TXT',
+} as const;
+
type RecordInsights = {
[key in RecordType]: Array<{
test: RegExp;
diff --git a/lib/resolvers/base-doh.ts b/lib/resolvers/base-doh.ts
index 7af5573..92be6dc 100644
--- a/lib/resolvers/base-doh.ts
+++ b/lib/resolvers/base-doh.ts
@@ -1,9 +1,5 @@
-import {
- DnsResolver,
- RECORD_TYPES_BY_DECIMAL,
- type RecordType,
- type ResolverResponse,
-} from './base';
+import { RECORD_TYPES_BY_DECIMAL } from '../data';
+import { DnsResolver, type RecordType, type ResolverResponse } from './base';
type DoHResponse = {
Status: number;
diff --git a/lib/resolvers/base.test.ts b/lib/resolvers/base.test.ts
index 438b1bf..8b968f9 100644
--- a/lib/resolvers/base.test.ts
+++ b/lib/resolvers/base.test.ts
@@ -1,11 +1,8 @@
import { describe, expect, it } from 'vitest';
-import {
- ALL_RECORD_TYPES,
- DnsResolver,
- type RecordType,
- type ResolverResponse,
-} from './base';
+import { ALL_RECORD_TYPES } from '@/lib/data';
+
+import { DnsResolver, type RecordType, type ResolverResponse } from './base';
class MockResolver extends DnsResolver {
public async resolveRecordType(
diff --git a/lib/resolvers/base.ts b/lib/resolvers/base.ts
index 8d8e83b..1c0620e 100644
--- a/lib/resolvers/base.ts
+++ b/lib/resolvers/base.ts
@@ -1,34 +1,4 @@
-export const ALL_RECORD_TYPES = [
- 'A',
- 'AAAA',
- 'CAA',
- 'CNAME',
- 'DNSKEY',
- 'DS',
- 'MX',
- 'NAPTR',
- 'NS',
- 'PTR',
- 'SOA',
- 'SRV',
- 'TXT',
-] as const;
-
-export const RECORD_TYPES_BY_DECIMAL = {
- 1: 'A',
- 28: 'AAAA',
- 257: 'CAA',
- 5: 'CNAME',
- 48: 'DNSKEY',
- 43: 'DS',
- 15: 'MX',
- 35: 'NAPTR',
- 2: 'NS',
- 12: 'PTR',
- 6: 'SOA',
- 33: 'SRV',
- 16: 'TXT',
-} as const;
+import type { ALL_RECORD_TYPES } from '@/lib/data';
export type RecordType = (typeof ALL_RECORD_TYPES)[number];