Skip to content

Commit

Permalink
feat: implement DNS query checking upon archive get (#130)
Browse files Browse the repository at this point in the history
- Add DNS refresh logic before fetching records
- Use existing refreshKeysFromDns function to update timestamps
- Maintain rate limiting and error handling

Co-Authored-By: Yush G <[email protected]>
  • Loading branch information
devin-ai-integration[bot] and Divide-By-0 committed Dec 24, 2024
1 parent 25719ca commit c85d4a0
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/app/api/key/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { NextRequest, NextResponse } from "next/server";
import { headers } from "next/headers";
import { RateLimiterMemory } from "rate-limiter-flexible";
import { checkRateLimiter } from "@/lib/utils";
import { prisma } from "@/lib/db";
import { refreshKeysFromDns } from "@/lib/utils_server";

export type DomainSearchResults = {
domain: string;
Expand All @@ -27,6 +29,18 @@ export async function GET(request: NextRequest) {
if (!domainName) {
return NextResponse.json('missing domain parameter', { status: 400 });
}

// Fetch all domain/selector pairs for this domain and refresh their DNS records
const dsps = await prisma.domainSelectorPair.findMany({
where: { domain: domainName }
});

// Refresh DNS records for each domain/selector pair
for (const dsp of dsps) {
await refreshKeysFromDns(dsp);
}

// Now fetch the updated records
let records = await findRecords(domainName);
let result: DomainSearchResults[] = records.map((record) => ({
domain: record.domainSelectorPair.domain,
Expand Down

0 comments on commit c85d4a0

Please sign in to comment.