Prokbun API fix

This commit is contained in:
2026-02-25 13:49:46 -05:00
parent 0a63e05028
commit 74b8f1113e
3 changed files with 20 additions and 10 deletions
+11 -5
View File
@@ -93,13 +93,19 @@ class PorkBun extends DnsApi{
});
}
async createRecord(domain, options, force){
if(force){
await this.deleteRecords(domain, options)
}
async createRecord(domain, options, force = true){
try{
// Throw errors for missing keys, do this first.
options = this.__parseOptions(options, ['type', 'name', 'data']);
// Delete the current records
if(force){
let forceOptions = new Map(Object.entries(options));
forceOptions.delete('data');
forceOptions.delete('content');
await this.deleteRecords(domain, Object.fromEntries(forceOptions));
}
let res = await this.post(`/dns/create/${domain}`, options);
return res.data.result;