//native
type Vercel = {
token: string;
};
/**
* Update an existing DNS record
* Updates an existing DNS record for a domain name.
*/
export async function main(
auth: Vercel,
recordId: string,
teamId: string | undefined,
slug: string | undefined,
body: {
additionalProperties?: never;
name?: string;
value?: string;
type?:
| "A"
| "AAAA"
| "ALIAS"
| "CAA"
| "CNAME"
| "HTTPS"
| "MX"
| "SRV"
| "TXT"
| "NS";
ttl?: number;
mxPriority?: number;
srv?: { target: string; weight: number; port: number; priority: number };
https?: { priority: number; target: string; params?: string };
comment?: string;
},
) {
const url = new URL(`https://api.vercel.com/v1/domains/records/${recordId}`);
for (const [k, v] of [
["teamId", teamId],
["slug", slug],
]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 428 days ago