Prokbun API fix
This commit is contained in:
@@ -182,17 +182,21 @@ if(require.main === module){(async function(){try{
|
||||
|
||||
// console.log(await DnsProvider.findall());
|
||||
|
||||
let provider = await DnsProvider.get('e8443e03ac503c7b');
|
||||
let provider = await DnsProvider.get('84c6613b9464fbe1');
|
||||
|
||||
console.log(await provider.listDomains())
|
||||
// console.log(await provider.listDomains())
|
||||
|
||||
let domain = await Domain.get('holycore.quest') // pork
|
||||
// let domain = await Domain.get('rm-rf.stream') // DO
|
||||
// let domain = await Domain.get('test.wtf') // CF
|
||||
|
||||
// console.log(await domain.createRecord({type: 'TXT', name: 'apitewefweefwsewft222', data:'hiiiiiii'}))
|
||||
console.log(await domain.createRecord({
|
||||
type: 'TXT',
|
||||
name: 'apitewefweefwsewft222',
|
||||
data: 'sdddddddad'
|
||||
}));
|
||||
|
||||
let txtRecords = await domain.getRecords({type: 'TXT'});
|
||||
let txtRecords = await domain.getRecords();
|
||||
console.log(txtRecords.map(i=>`${i.name}: ${i.data}`))
|
||||
// console.log(await domain.deleteRecords({type: 'TXT'}))
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user