Skip to content

Commit 10c2772

Browse files
authored
fix: persist record comments (#139)
* chore: clean up ts errors * fix: persist record comments
1 parent 8f73cdc commit 10c2772

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

src/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ async function update(clientOptions: ClientOptions, newRecord: AddressableRecord
7474
const records = (
7575
await cloudflare.dns.records.list({
7676
zone_id: zone.id,
77-
name: newRecord.name,
77+
name: newRecord.name as any,
7878
type: newRecord.type,
7979
})
8080
).result;
@@ -85,19 +85,21 @@ async function update(clientOptions: ClientOptions, newRecord: AddressableRecord
8585
throw new HttpError(400, 'No record found! You must first manually create the record.');
8686
}
8787

88-
// Extract the current `proxied` status
88+
// Extract current properties
8989
const currentRecord = records[0] as AddressableRecord;
9090
const proxied = currentRecord.proxied ?? false; // Default to `false` if `proxied` is undefined
91+
const comment = currentRecord.comment;
9192

9293
await cloudflare.dns.records.update(records[0].id, {
9394
content: newRecord.content,
9495
zone_id: zone.id,
95-
name: newRecord.name,
96+
name: newRecord.name as any,
9697
type: newRecord.type,
9798
proxied, // Pass the existing "proxied" status
99+
comment, // Pass the existing "comment"
98100
});
99101

100-
console.log('DNS record for ' + newRecord.name + '(' + newRecord.type +') updated successfully to ' + newRecord.content);
102+
console.log('DNS record for ' + newRecord.name + '(' + newRecord.type + ') updated successfully to ' + newRecord.content);
101103

102104
return new Response('OK', { status: 200 });
103105
}
@@ -107,9 +109,7 @@ export default {
107109
const url = new URL(request.url);
108110
console.log('Requester IP: ' + request.headers.get('CF-Connecting-IP'));
109111
console.log(request.method + ': ' + request.url);
110-
if (request.body) {
111-
console.log('Body: ' + await request.text());
112-
}
112+
console.log('Body: ' + (await request.text()));
113113

114114
try {
115115
// Construct client options and DNS record

0 commit comments

Comments
 (0)