diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 0bc3b42..d401a77 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,7 +5,7 @@ updates: schedule: interval: daily time: "10:00" - open-pull-requests-limit: 10 + open-pull-requests-limit: 20 commit-message: prefix: "deps" prefix-development: "deps(dev)" diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..f8966ba --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,29 @@ +## Title + + + +## Description + + + +## Notes & open questions + + + +## Change checklist + +- [ ] I have performed a self-review of my own code +- [ ] I have made corresponding changes to the documentation if necessary (this includes comments as well) +- [ ] I have added tests that prove my fix is effective or that my feature works diff --git a/.github/workflows/js-test-and-release.yml b/.github/workflows/js-test-and-release.yml index 35d87d1..2806813 100644 --- a/.github/workflows/js-test-and-release.yml +++ b/.github/workflows/js-test-and-release.yml @@ -9,7 +9,9 @@ on: permissions: contents: write + id-token: write packages: write + pull-requests: write concurrency: group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event_name == 'push' && github.sha || github.ref }} @@ -17,9 +19,10 @@ concurrency: jobs: js-test-and-release: - uses: pl-strflt/uci/.github/workflows/js-test-and-release.yml@v0.0 + uses: ipdxco/unified-github-workflows/.github/workflows/js-test-and-release.yml@v1.0 secrets: DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }} DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} UCI_GITHUB_TOKEN: ${{ secrets.UCI_GITHUB_TOKEN }} + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/semantic-pull-request.yml b/.github/workflows/semantic-pull-request.yml new file mode 100644 index 0000000..bd00f09 --- /dev/null +++ b/.github/workflows/semantic-pull-request.yml @@ -0,0 +1,12 @@ +name: Semantic PR + +on: + pull_request_target: + types: + - opened + - edited + - synchronize + +jobs: + main: + uses: pl-strflt/.github/.github/workflows/reusable-semantic-pull-request.yml@v0.3 diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 0000000..16d65d7 --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,13 @@ +name: Close and mark stale issue + +on: + schedule: + - cron: '0 0 * * *' + +permissions: + issues: write + pull-requests: write + +jobs: + stale: + uses: pl-strflt/.github/.github/workflows/reusable-stale-issue.yml@v0.3 diff --git a/package.json b/package.json index 2b0cf34..a9b04e5 100644 --- a/package.json +++ b/package.json @@ -135,11 +135,10 @@ "docs": "aegir docs" }, "dependencies": { - "debug": "^4.3.4", - "receptacle": "^1.3.2" + "quick-lru": "^7.0.0", + "weald": "^1.0.2" }, "devDependencies": { - "@types/debug": "^4.1.7", "@types/sinon": "^17.0.3", "aegir": "^44.0.0", "sinon": "^18.0.0" diff --git a/src/index.ts b/src/index.ts index ae2cbf6..1775358 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,5 @@ -import debug from 'debug' -import Receptacle from 'receptacle' +import QuickLRU from 'quick-lru' +import debug from 'weald' import * as utils from './utils.js' import type { DNSJSON } from './utils' @@ -19,8 +19,8 @@ interface ResolverOptions { * Uses a list of servers to resolve DNS records with HTTP requests. */ class Resolver { - private readonly _cache: Receptacle - private readonly _TXTcache: Receptacle + private readonly _cache: QuickLRU + private readonly _TXTcache: QuickLRU private _servers: string[] private readonly _request: Request private _abortControllers: AbortController[] @@ -32,8 +32,8 @@ class Resolver { * @param {Request} [options.request] - function to return DNSJSON */ constructor (options: ResolverOptions = {}) { - this._cache = new Receptacle({ max: options?.maxCache ?? 100 }) - this._TXTcache = new Receptacle({ max: options?.maxCache ?? 100 }) + this._cache = new QuickLRU({ maxSize: options?.maxCache ?? 100 }) + this._TXTcache = new QuickLRU({ maxSize: options?.maxCache ?? 100 }) this._servers = [ 'https://cloudflare-dns.com/dns-query', 'https://dns.google/resolve' @@ -133,7 +133,7 @@ class Resolver { const data = response.Answer.map(a => a.data) const ttl = Math.min(...response.Answer.map(a => a.TTL)) - this._cache.set(utils.getCacheKey(hostname, recordType), data, { ttl }) + this._cache.set(utils.getCacheKey(hostname, recordType), data, { maxAge: ttl }) return data } catch (err) { @@ -183,7 +183,7 @@ class Resolver { const data = response.Answer.map(a => a.data) const ttl = Math.min(...response.Answer.map(a => a.TTL)) - this._cache.set(utils.getCacheKey(hostname, recordType), data, { ttl }) + this._cache.set(utils.getCacheKey(hostname, recordType), data, { maxAge: ttl }) return data } catch (err) { @@ -233,7 +233,7 @@ class Resolver { const data = response.Answer.map(a => [a.data.replace(/['"]+/g, '')]) const ttl = Math.min(...response.Answer.map(a => a.TTL)) - this._TXTcache.set(utils.getCacheKey(hostname, recordType), data, { ttl }) + this._TXTcache.set(utils.getCacheKey(hostname, recordType), data, { maxAge: ttl }) return data } catch (err) {