Skip to content

Commit

Permalink
Removed harcoded record limit, we get them all. Improved record search.
Browse files Browse the repository at this point in the history
  • Loading branch information
luisfavila committed Oct 6, 2019
1 parent 620e094 commit a6ddd05
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cloudflare-dns",
"version": "1.0.2",
"version": "1.0.3",
"description": "Extended CloudFlare API",
"author": "Luis Ávila <[email protected]",
"repository": {
Expand Down
14 changes: 12 additions & 2 deletions src/dns/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,18 @@ export default function (cloudflare) {
}

async function findRecord(zone, record) {
const response = await cloudflare.dnsRecords.browse(zone, { per_page: 40 })
const records = normalize(response.result)
let info = {
page: 0,
total_pages: 1
}
const results = []
while (info.page < info.total_pages) {
/* eslint-disable-next-line */
const response = await cloudflare.dnsRecords.browse(zone, { type: record.type, name: record.name, per_page: 100 })
info = response.result_info || { page: 1, total_pages: 1 }
results.push(...response.result)
}
const records = normalize(results)
return records.find(r => record.isEqual(r))
}

Expand Down

0 comments on commit a6ddd05

Please sign in to comment.