mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
Fix records query
This commit is contained in:
@@ -21,7 +21,8 @@ interface DNSMadeEasyApiResponse {
|
||||
data: Array<{
|
||||
id: number;
|
||||
name: string;
|
||||
[key: string]: unknown;
|
||||
type: string;
|
||||
value: string;
|
||||
}>;
|
||||
page: number;
|
||||
}
|
||||
@@ -124,7 +125,6 @@ export const listDNSMadeEasyRecords = async (
|
||||
if (appConnection.method !== DNSMadeEasyConnectionMethod.APIKeySecret) {
|
||||
throw new Error("Unsupported DNS Made Easy connection method");
|
||||
}
|
||||
|
||||
const {
|
||||
credentials: { apiKey, secretKey }
|
||||
} = appConnection;
|
||||
@@ -138,14 +138,14 @@ export const listDNSMadeEasyRecords = async (
|
||||
// Fetch all pages of records
|
||||
while (currentPage < totalPages) {
|
||||
// Build query parameters
|
||||
const queryParams: Array<[string, string | number]> = [];
|
||||
const queryParams: Record<string, string | number> = {};
|
||||
if (type) {
|
||||
queryParams.push(["type", type]);
|
||||
queryParams.type = type;
|
||||
}
|
||||
if (name) {
|
||||
queryParams.push(["recordName", name]);
|
||||
queryParams.recordName = name;
|
||||
}
|
||||
queryParams.push(["page", currentPage]);
|
||||
queryParams.page = currentPage;
|
||||
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
const resp = await request.get<DNSMadeEasyApiResponse>(
|
||||
|
||||
@@ -4,6 +4,7 @@ import { request } from "@app/lib/config/request";
|
||||
import { logger } from "@app/lib/logger";
|
||||
import {
|
||||
getDNSMadeEasyUrl,
|
||||
listDNSMadeEasyRecords,
|
||||
makeDNSMadeEasyAuthHeaders
|
||||
} from "@app/services/app-connection/dns-made-easy/dns-made-easy-connection-fns";
|
||||
import { TDNSMadeEasyConnection } from "@app/services/app-connection/dns-made-easy/dns-made-easy-connection-types";
|
||||
@@ -67,21 +68,7 @@ export const dnsMadeEasyDeleteTxtRecord = async (
|
||||
|
||||
logger.info({ hostedZoneId, domain }, "Deleting TXT record for DNS Made Easy");
|
||||
try {
|
||||
// First, list records to find the record ID
|
||||
const listRecordsResponse = await request.get<{
|
||||
data: Array<{ id: number; type: string; name: string; value: string }>;
|
||||
}>(getDNSMadeEasyUrl(`/V2.0/dns/managed/${encodeURIComponent(hostedZoneId)}/records`), {
|
||||
headers: {
|
||||
...makeDNSMadeEasyAuthHeaders(apiKey, secretKey),
|
||||
Accept: "application/json"
|
||||
},
|
||||
params: {
|
||||
type: "TXT",
|
||||
recordName: domain
|
||||
}
|
||||
});
|
||||
|
||||
const dnsRecords = listRecordsResponse.data?.data;
|
||||
const dnsRecords = await listDNSMadeEasyRecords(connection, { zoneId: hostedZoneId, type: "TXT", name: domain });
|
||||
|
||||
if (Array.isArray(dnsRecords) && dnsRecords.length > 0) {
|
||||
const recordToDelete = dnsRecords.find(
|
||||
|
||||
Reference in New Issue
Block a user